Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,27 +3,23 @@ from PIL import Image
|
|
| 3 |
import torch
|
| 4 |
from diffusers import StableDiffusionUpscalePipeline
|
| 5 |
|
|
|
|
| 6 |
model_id = "Kim2091/UltraSharpV2"
|
| 7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
-
pipe = StableDiffusionUpscalePipeline.from_pretrained(
|
| 10 |
-
model_id,
|
| 11 |
-
torch_dtype=torch.float16 if device == "cuda" else torch.float32
|
| 12 |
-
)
|
| 13 |
pipe = pipe.to(device)
|
| 14 |
|
| 15 |
-
def enhance_image(
|
| 16 |
-
|
| 17 |
-
return result
|
| 18 |
|
| 19 |
demo = gr.Interface(
|
| 20 |
fn=enhance_image,
|
| 21 |
inputs=gr.Image(type="pil"),
|
| 22 |
outputs=gr.Image(type="pil"),
|
| 23 |
-
title="UltraSharpV2
|
| 24 |
-
description="
|
| 25 |
allow_flagging="never"
|
| 26 |
)
|
| 27 |
|
| 28 |
-
|
| 29 |
-
demo.launch()
|
|
|
|
| 3 |
import torch
|
| 4 |
from diffusers import StableDiffusionUpscalePipeline
|
| 5 |
|
| 6 |
+
# UltraSharpV2
|
| 7 |
model_id = "Kim2091/UltraSharpV2"
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
|
| 10 |
+
pipe = StableDiffusionUpscalePipeline.from_pretrained(model_id)
|
|
|
|
|
|
|
|
|
|
| 11 |
pipe = pipe.to(device)
|
| 12 |
|
| 13 |
+
def enhance_image(image: Image.Image) -> Image.Image:
|
| 14 |
+
return pipe(image).images[0]
|
|
|
|
| 15 |
|
| 16 |
demo = gr.Interface(
|
| 17 |
fn=enhance_image,
|
| 18 |
inputs=gr.Image(type="pil"),
|
| 19 |
outputs=gr.Image(type="pil"),
|
| 20 |
+
title="UltraSharpV2 Enhancer",
|
| 21 |
+
description="Enhances and upscales images (faces, objects, text).",
|
| 22 |
allow_flagging="never"
|
| 23 |
)
|
| 24 |
|
| 25 |
+
demo.launch()
|
|
|