sunbv56 commited on
Commit
747613a
·
verified ·
1 Parent(s): 5593abd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -83,23 +83,27 @@ async def process_request(images, text, num_requests):
83
  resized_images = [img.resize((2560, int(img.height * (2560 / img.width))), Image.LANCZOS) for img in results] # Resize giữ nguyên tỉ lệ chiều cao
84
  # srcnn_images = [upscale_image(img) for img in resized_images]
85
 
86
- return resized_images
 
87
 
88
- def gradio_interface(images, text, num_requests):
89
  """Hàm Gradio xử lý yêu cầu và trả về ảnh"""
 
90
  return asyncio.run(process_request(images, text, num_requests))
91
 
92
  # Tạo giao diện Gradio
93
  demo = gr.Interface(
94
  fn=gradio_interface,
95
  inputs=[
96
- gr.File(file_types=["image"], label="Upload hình ảnh"),
 
 
97
  gr.Textbox(label="Nhập yêu cầu chỉnh sửa hình ảnh"),
98
  gr.Slider(minimum=1, maximum=4, step=1, value=4, label="Số lượng ảnh cần tạo")
99
  ],
100
  outputs=gr.Gallery(label="Kết quả chỉnh sửa", columns=4),
101
  title="Chỉnh sửa ảnh bằng Gemini AI + SRCNN",
102
- description="Upload nhiều ảnh và nhập yêu cầu chỉnh sửa. Hiển thị ảnh gốc từ API và ảnh đã qua SRCNN.",
103
  )
104
 
105
  demo.launch()
 
83
  resized_images = [img.resize((2560, int(img.height * (2560 / img.width))), Image.LANCZOS) for img in results] # Resize giữ nguyên tỉ lệ chiều cao
84
  # srcnn_images = [upscale_image(img) for img in resized_images]
85
 
86
+ return results + resized_images
87
+ # return results + srcnn_images # Ảnh gốc + ảnh đã qua SRCNN
88
 
89
+ def gradio_interface(image1, image2, image3, text, num_requests):
90
  """Hàm Gradio xử lý yêu cầu và trả về ảnh"""
91
+ images = [img for img in [image1, image2, image3] if img]
92
  return asyncio.run(process_request(images, text, num_requests))
93
 
94
  # Tạo giao diện Gradio
95
  demo = gr.Interface(
96
  fn=gradio_interface,
97
  inputs=[
98
+ gr.Image(type='filepath', label="Upload hình ảnh 1"),
99
+ gr.Image(type='filepath', label="Upload hình ảnh 2"),
100
+ gr.Image(type='filepath', label="Upload hình ảnh 3"),
101
  gr.Textbox(label="Nhập yêu cầu chỉnh sửa hình ảnh"),
102
  gr.Slider(minimum=1, maximum=4, step=1, value=4, label="Số lượng ảnh cần tạo")
103
  ],
104
  outputs=gr.Gallery(label="Kết quả chỉnh sửa", columns=4),
105
  title="Chỉnh sửa ảnh bằng Gemini AI + SRCNN",
106
+ description="Upload tối đa 3 ảnh và nhập yêu cầu chỉnh sửa. Hiển thị ảnh gốc từ API và ảnh đã qua SRCNN.",
107
  )
108
 
109
  demo.launch()