Ahsen Khaliq commited on
Commit
f6d5d0f
·
1 Parent(s): 07e3566

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -4,6 +4,7 @@ os.system("hub install UGATIT_100w==1.0.0")
4
  import gradio as gr
5
  import paddlehub as hub
6
  import numpy as np
 
7
 
8
  model = hub.Module(name='UGATIT_100w', use_gpu=False)
9
 
@@ -12,11 +13,11 @@ def inference(image):
12
  result = model.style_transfer(paths=[image.name])
13
  print(type(result[0]))
14
  print(result[0])
15
- return (result[0]* 255).astype(np.uint8).convert('RGB')
16
 
17
  title = "UGATIT-selfie2anime"
18
  description = "Gradio demo for DeOldify. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
19
  article = "<p style='text-align: center'><a href='https://github.com/jantic/DeOldify' target='_blank'>Github Repo</a></p>"
20
  examples=[['pearl.png']]
21
- iface = gr.Interface(inference, inputs=gr.inputs.Image(type="file"), outputs=gr.outputs.Image(type="numpy"),examples=examples,enable_queue=True,title=title,article=article,description=description)
22
  iface.launch()
 
4
  import gradio as gr
5
  import paddlehub as hub
6
  import numpy as np
7
+ from PIL import Image
8
 
9
  model = hub.Module(name='UGATIT_100w', use_gpu=False)
10
 
 
13
  result = model.style_transfer(paths=[image.name])
14
  print(type(result[0]))
15
  print(result[0])
16
+ return Image.fromarray(np.uint8(result[0])).convert('RGB')
17
 
18
  title = "UGATIT-selfie2anime"
19
  description = "Gradio demo for DeOldify. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
20
  article = "<p style='text-align: center'><a href='https://github.com/jantic/DeOldify' target='_blank'>Github Repo</a></p>"
21
  examples=[['pearl.png']]
22
+ iface = gr.Interface(inference, inputs=gr.inputs.Image(type="file"), outputs=gr.outputs.Image(type="pil"),examples=examples,enable_queue=True,title=title,article=article,description=description)
23
  iface.launch()