Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
-
from
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
# ฟังก์ชันสำหรับการอัปสเกลภาพ
|
7 |
def upscale_image(image):
|
8 |
-
#
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
# ใช้โมเดลในการอัปเกรดภาพ
|
13 |
-
upscaler = UpscaleWithModel.from_pretrained(model_selection).to("cuda")
|
14 |
-
upscaled_image = upscaler(original, tiling=True, tile_width=1024, tile_height=1024)
|
15 |
-
|
16 |
-
return original, upscaled_image
|
17 |
|
18 |
# UI with Gradio
|
19 |
with gr.Blocks() as demo:
|
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
+
from diffusers import StableDiffusionUpscalePipeline
|
4 |
+
import torch
|
5 |
+
|
6 |
+
# โหลดโมเดล
|
7 |
+
model_id = "stabilityai/stable-diffusion-x4-upscaler"
|
8 |
+
pipeline = StableDiffusionUpscalePipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
9 |
+
pipeline = pipeline.to("cuda")
|
10 |
|
11 |
# ฟังก์ชันสำหรับการอัปสเกลภาพ
|
12 |
def upscale_image(image):
|
13 |
+
# การอัปสเกลภาพ
|
14 |
+
upscaled_image = pipeline(image=image).images[0]
|
15 |
+
return upscaled_image
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# UI with Gradio
|
18 |
with gr.Blocks() as demo:
|