Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from PIL import Image | |
| import torch | |
| from diffusers import StableDiffusionUpscalePipeline | |
| # UltraSharpV2 | |
| model_id = "Kim2091/UltraSharpV2" | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| pipe = StableDiffusionUpscalePipeline.from_pretrained(model_id) | |
| pipe = pipe.to(device) | |
| def enhance_image(image: Image.Image) -> Image.Image: | |
| return pipe(image).images[0] | |
| demo = gr.Interface( | |
| fn=enhance_image, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Image(type="pil"), | |
| title="UltraSharpV2 Enhancer", | |
| description="Enhances and upscales images (faces, objects, text).", | |
| allow_flagging="never" | |
| ) | |
| demo.launch() | |