Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
def enhance_image(input_image):
|
| 12 |
+
# input_image is a PIL.Image
|
| 13 |
+
result = pipe(input_image).images[0]
|
| 14 |
+
return result
|
| 15 |
+
|
| 16 |
+
title = "UltraSharpV2 Image Enhancer"
|
| 17 |
+
description = "Upload an image and UltraSharpV2 will enhance it (faces, objects, text, general quality)."
|
| 18 |
+
|
| 19 |
+
demo = gr.Interface(
|
| 20 |
+
fn=enhance_image,
|
| 21 |
+
inputs=gr.Image(type="pil"),
|
| 22 |
+
outputs=gr.Image(type="pil"),
|
| 23 |
+
title=title,
|
| 24 |
+
description=description,
|
| 25 |
+
allow_flagging="never"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
demo.launch()
|