Ahsen Khaliq commited on
Commit
85a0fdf
1 Parent(s): 039608b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -15,7 +15,7 @@ device = "cpu"
15
  model = Generator().eval().to(device)
16
  model.load_state_dict(torch.load("face_paint_512_v2_0.pt"))
17
 
18
- from PIL import Image
19
  from torchvision.transforms.functional import to_tensor, to_pil_image
20
  import gradio as gr
21
 
@@ -55,7 +55,7 @@ import scipy.ndimage
55
  import requests
56
 
57
  def inference(image):
58
- img = image
59
  out = face2paint(img, 512)
60
  return out
61
 
@@ -65,4 +65,4 @@ description = "Gradio demo for AnimeGanv2 Face Portrait v2. To use it, simply up
65
  article = "<p style='text-align: center'><a href='https://github.com/bryandlee/animegan2-pytorch' target='_blank'>Github Repo</a></p>"
66
 
67
  examples=[['groot.jpeg']]
68
- gr.Interface(inference, gr.inputs.Image(type="pil",shape=(512,512)), gr.outputs.Image(type="pil"),title=title,description=description,article=article,examples=examples,enable_queue=True).launch()
 
15
  model = Generator().eval().to(device)
16
  model.load_state_dict(torch.load("face_paint_512_v2_0.pt"))
17
 
18
+ from PIL import Image, ImageOps
19
  from torchvision.transforms.functional import to_tensor, to_pil_image
20
  import gradio as gr
21
 
 
55
  import requests
56
 
57
  def inference(image):
58
+ img = ImageOps.contain(image, (512,512))
59
  out = face2paint(img, 512)
60
  return out
61
 
 
65
  article = "<p style='text-align: center'><a href='https://github.com/bryandlee/animegan2-pytorch' target='_blank'>Github Repo</a></p>"
66
 
67
  examples=[['groot.jpeg']]
68
+ gr.Interface(inference, gr.inputs.Image(type="pil"), gr.outputs.Image(type="pil"),title=title,description=description,article=article,examples=examples,enable_queue=True).launch()