mr2along commited on
Commit
108033f
·
verified ·
1 Parent(s): 3004b31

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +26 -22
run.py CHANGED
@@ -1,25 +1,29 @@
1
  import gradio as gr
 
 
 
2
 
3
- with gr.Blocks() as demo:
4
- gr.Markdown("""
5
- # ⬆️📁 max_file_size test
6
- The demo has a max file size of 15kb. The error modal should pop up when a file larger than that is uploaded.
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
- if __name__ == "__main__":
23
- # The upload limit is set in playwright_setup.js
24
- # since the e2e tests use mount_gradio_app
25
- demo.launch(max_file_size="10mb")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from PIL import Image
3
+ import torch
4
+ from transformers import AutoModel, AutoTokenizer
5
 
6
+ # Tải 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ử 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()