Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
from
|
| 4 |
|
| 5 |
# ฟังก์ชันสำหรับการอัปสเกลภาพ
|
| 6 |
def upscale_image(image):
|
| 7 |
-
|
| 8 |
-
original = load_image(image) # สมมติว่ามีฟังก์ชันนี้ที่โหลดภาพ
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
|
|
|
| 12 |
upscaled_image = upscaler(original, tiling=True, tile_width=1024, tile_height=1024)
|
| 13 |
|
| 14 |
return original, upscaled_image
|
| 15 |
|
| 16 |
-
# ฟังก์ชันสำหรับการเคลียร์ผลลัพธ์
|
| 17 |
-
def clear_result():
|
| 18 |
-
return gr.update(value=None)
|
| 19 |
-
|
| 20 |
-
# Title แค่ "Image Upscaler"
|
| 21 |
-
title = """<h1 align="center">Image Upscaler</h1>"""
|
| 22 |
-
|
| 23 |
# UI with Gradio
|
| 24 |
with gr.Blocks() as demo:
|
| 25 |
-
gr.HTML(
|
| 26 |
|
| 27 |
with gr.Row():
|
| 28 |
with gr.Column():
|
|
@@ -35,12 +28,8 @@ with gr.Blocks() as demo:
|
|
| 35 |
# Result Image with slider for comparison
|
| 36 |
result = gr.Image(label="Generated Image", interactive=False)
|
| 37 |
|
| 38 |
-
# เมื่อกดปุ่ม "Upscale" จะเรียกฟังก์ชัน
|
| 39 |
run_button.click(
|
| 40 |
-
fn=clear_result, # เคลียร์ผลลัพธ์ก่อน
|
| 41 |
-
inputs=None,
|
| 42 |
-
outputs=result,
|
| 43 |
-
).then(
|
| 44 |
fn=upscale_image, # อัปสเกลภาพ
|
| 45 |
inputs=[input_image],
|
| 46 |
outputs=result, # แสดงผลลัพธ์ภาพที่อัปสเกล
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from image_gen_aux import UpscaleWithModel
|
| 3 |
+
from image_gen_aux.utils import load_image
|
| 4 |
|
| 5 |
# ฟังก์ชันสำหรับการอัปสเกลภาพ
|
| 6 |
def upscale_image(image):
|
| 7 |
+
original = load_image(image)
|
|
|
|
| 8 |
|
| 9 |
+
# โหลดโมเดลที่ต้องการใช้งาน
|
| 10 |
+
model_selection = "4xNomosWebPhoto_esrgan" # กำหนดชื่อโมเดล
|
| 11 |
+
upscaler = UpscaleWithModel.from_pretrained(model_selection).to("cuda")
|
| 12 |
upscaled_image = upscaler(original, tiling=True, tile_width=1024, tile_height=1024)
|
| 13 |
|
| 14 |
return original, upscaled_image
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# UI with Gradio
|
| 17 |
with gr.Blocks() as demo:
|
| 18 |
+
gr.HTML("<h1 align='center'>Image Upscaler</h1>")
|
| 19 |
|
| 20 |
with gr.Row():
|
| 21 |
with gr.Column():
|
|
|
|
| 28 |
# Result Image with slider for comparison
|
| 29 |
result = gr.Image(label="Generated Image", interactive=False)
|
| 30 |
|
| 31 |
+
# เมื่อกดปุ่ม "Upscale" จะเรียกฟังก์ชัน upscale_image
|
| 32 |
run_button.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
fn=upscale_image, # อัปสเกลภาพ
|
| 34 |
inputs=[input_image],
|
| 35 |
outputs=result, # แสดงผลลัพธ์ภาพที่อัปสเกล
|