AhmadFiaz commited on
Commit
03b5a35
·
verified ·
1 Parent(s): 01e950c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
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(input_image: Image.Image) -> Image.Image:
16
- result = pipe(input_image).images[0]
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 Image Enhancer",
24
- description="Upload an image and UltraSharpV2 will enhance it.",
25
  allow_flagging="never"
26
  )
27
 
28
- if __name__ == "__main__":
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()