Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from diffusers import StableDiffusionUpscalePipeline
|
| 3 |
-
import torch
|
| 4 |
from PIL import Image
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
# Load model
|
| 7 |
model_id = "Kim2091/UltraSharpV2"
|
| 8 |
-
pipe = StableDiffusionUpscalePipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 9 |
-
pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
result = pipe(input_image).images[0]
|
| 14 |
return result
|
| 15 |
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
+
import torch
|
| 4 |
+
from diffusers import StableDiffusionUpscalePipeline
|
| 5 |
|
| 6 |
+
# Load UltraSharpV2 model
|
| 7 |
model_id = "Kim2091/UltraSharpV2"
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
+
|
| 11 |
+
pipe = StableDiffusionUpscalePipeline.from_pretrained(
|
| 12 |
+
model_id,
|
| 13 |
+
torch_dtype=torch.float16 if device=="cuda" else torch.float32
|
| 14 |
+
)
|
| 15 |
+
pipe = pipe.to(device)
|
| 16 |
+
|
| 17 |
+
def enhance_image(input_image: Image.Image) -> Image.Image:
|
| 18 |
+
"""
|
| 19 |
+
Enhance and upscale input image using UltraSharpV2.
|
| 20 |
+
"""
|
| 21 |
result = pipe(input_image).images[0]
|
| 22 |
return result
|
| 23 |
|