Spaces:
Runtime error
Runtime error
Update run.py
Browse files
run.py
CHANGED
|
@@ -1,25 +1,29 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
""")
|
| 8 |
-
with gr.Row():
|
| 9 |
-
with gr.Column():
|
| 10 |
-
gr.Image(label="Image", interactive=True)
|
| 11 |
-
gr.Gallery(label="Gallery", interactive=True)
|
| 12 |
-
gr.File(label="Single File", file_count="single")
|
| 13 |
-
with gr.Column():
|
| 14 |
-
gr.Model3D(label="Model 3D", interactive=True,)
|
| 15 |
-
gr.MultimodalTextbox(label="Multimodal Textbox", interactive=True)
|
| 16 |
-
gr.UploadButton(label="Upload Button", interactive=True)
|
| 17 |
-
with gr.Column():
|
| 18 |
-
gr.Video(label="Video", interactive=True)
|
| 19 |
-
gr.Audio(label="Audio", interactive=True)
|
| 20 |
-
gr.File(label="Multiple Files", interactive=True, file_count="multiple")
|
| 21 |
|
| 22 |
-
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import torch
|
| 4 |
+
from transformers import AutoModel, AutoTokenizer
|
| 5 |
|
| 6 |
+
# Tải mô hình Kanbara
|
| 7 |
+
model_name = "Kanbara/doll-likeness-series"
|
| 8 |
+
model = AutoModel.from_pretrained(model_name)
|
| 9 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
def generate_image(source_img, target_img):
|
| 12 |
+
# Tiền xử lý hình ảnh
|
| 13 |
+
source_image = Image.open(source_img).convert("RGB")
|
| 14 |
+
target_image = Image.open(target_img).convert("RGB")
|
| 15 |
+
|
| 16 |
+
# Chuyển đổi hình ảnh sang tensor và tạo đầu ra
|
| 17 |
+
# (Thêm mã xử lý ở đây để tạo hình ảnh)
|
| 18 |
+
|
| 19 |
+
# Giả lập đầu ra để hiển thị
|
| 20 |
+
output_image = source_image # Đây chỉ là một ví dụ
|
| 21 |
+
return output_image
|
| 22 |
+
|
| 23 |
+
# Tạo giao diện Gradio
|
| 24 |
+
iface = gr.Interface(fn=generate_image,
|
| 25 |
+
inputs=["image", "image"],
|
| 26 |
+
outputs="image",
|
| 27 |
+
title="Tạo Hình Ảnh từ Hình Ảnh Nguồn và Mục Tiêu")
|
| 28 |
+
|
| 29 |
+
iface.launch()
|