Ahsen Khaliq commited on
Commit
1fe1457
1 Parent(s): 7fee812

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -3,7 +3,7 @@ from PIL import Image
3
  import torch
4
  import gradio as gr
5
 
6
-
7
  import torch
8
  torch.backends.cudnn.benchmark = True
9
  from torchvision import transforms, utils
@@ -28,9 +28,9 @@ os.makedirs('style_images', exist_ok=True)
28
  os.makedirs('style_images_aligned', exist_ok=True)
29
  os.makedirs('models', exist_ok=True)
30
 
31
- #os.system("wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2")
32
- #os.system("bzip2 -dk shape_predictor_68_face_landmarks.dat.bz2")
33
- #os.system("mv shape_predictor_68_face_landmarks.dat models/dlibshape_predictor_68_face_landmarks.dat")
34
 
35
 
36
  device = 'cpu'
@@ -66,7 +66,9 @@ plt.rcParams['figure.dpi'] = 150
66
  os.system("gdown https://drive.google.com/uc?id=1-8E0PFT37v5fZs-61oIrFbNpE28Unp2y")
67
 
68
  def inference(img):
69
- my_w = e4e_projection(img, "test.pt", device).unsqueeze(0)
 
 
70
 
71
 
72
  plt.rcParams['figure.dpi'] = 150
@@ -93,4 +95,4 @@ description = "Gradio Demo for JoJoGAN: One Shot Face Stylization. To use it, si
93
  article = "<p style='text-align: center'><a href='https://github.com/mchong6/JoJoGAN' target='_blank'>Github Repo Pytorch</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_jojogan' alt='visitor badge'></center> <p style='text-align: center'>samples from repo: <img src='https://raw.githubusercontent.com/mchong6/JoJoGAN/main/teaser.jpg' alt='animation'/></p>"
94
 
95
  examples=[['iu.jpeg']]
96
- gr.Interface(inference, [gr.inputs.Image(type="pil",shape=(512,512))], gr.outputs.Image(type="file"),title=title,description=description,article=article,enable_queue=True,allow_flagging=False,examples=examples).launch()
 
3
  import torch
4
  import gradio as gr
5
 
6
+ os.system("pip install dlib")
7
  import torch
8
  torch.backends.cudnn.benchmark = True
9
  from torchvision import transforms, utils
 
28
  os.makedirs('style_images_aligned', exist_ok=True)
29
  os.makedirs('models', exist_ok=True)
30
 
31
+ os.system("wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2")
32
+ os.system("bzip2 -dk shape_predictor_68_face_landmarks.dat.bz2")
33
+ os.system("mv shape_predictor_68_face_landmarks.dat models/dlibshape_predictor_68_face_landmarks.dat")
34
 
35
 
36
  device = 'cpu'
 
66
  os.system("gdown https://drive.google.com/uc?id=1-8E0PFT37v5fZs-61oIrFbNpE28Unp2y")
67
 
68
  def inference(img):
69
+ aligned_face = align_face(img)
70
+
71
+ my_w = e4e_projection(aligned_face, "test.pt", device).unsqueeze(0)
72
 
73
 
74
  plt.rcParams['figure.dpi'] = 150
 
95
  article = "<p style='text-align: center'><a href='https://github.com/mchong6/JoJoGAN' target='_blank'>Github Repo Pytorch</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_jojogan' alt='visitor badge'></center> <p style='text-align: center'>samples from repo: <img src='https://raw.githubusercontent.com/mchong6/JoJoGAN/main/teaser.jpg' alt='animation'/></p>"
96
 
97
  examples=[['iu.jpeg']]
98
+ gr.Interface(inference, [gr.inputs.Image(type="filepath",shape=(512,512))], gr.outputs.Image(type="file"),title=title,description=description,article=article,enable_queue=True,allow_flagging=False,examples=examples).launch()