Doron Adler commited on
Commit
b558187
·
1 Parent(s): d55cf7e

Re-Generate samples. Cleanups

Browse files
Files changed (7) hide show
  1. Sample00001.jpg +0 -0
  2. Sample00002.jpg +0 -0
  3. Sample00003.jpg +0 -0
  4. Sample00004.jpg +0 -0
  5. Sample00005.jpg +0 -0
  6. Sample00006.jpg +0 -0
  7. app.py +15 -18
Sample00001.jpg CHANGED
Sample00002.jpg CHANGED
Sample00003.jpg CHANGED
Sample00004.jpg CHANGED
Sample00005.jpg CHANGED
Sample00006.jpg CHANGED
app.py CHANGED
@@ -1,9 +1,10 @@
1
  import os
2
  os.system("pip install dlib")
 
3
  import sys
4
  import face_detection
5
  import PIL
6
- from PIL import Image, ImageOps
7
  import numpy as np
8
 
9
  import torch
@@ -81,26 +82,11 @@ def face2hero(
81
  else:
82
  input = torch.Tensor(aligned_img)
83
  results = model(input)
84
- d1 = array_to_image(results[0].detach().numpy())
85
  d2 = array_to_image(results[1].detach().numpy())
86
- d3 = array_to_image(results[2].detach().numpy())
87
- img_with_d2 = img_concat_h(array_to_image(aligned_img), d2)
88
- d1_with_d3 = img_concat_h(d1, d3)
89
- output = [img_with_d2, d1_with_d3]
90
  del results
91
 
92
  return output
93
-
94
- import os
95
- import collections
96
- from typing import Union, List
97
- import numpy as np
98
- from PIL import Image
99
- import PIL.Image
100
- import PIL.ImageFile
101
- import numpy as np
102
- import scipy.ndimage
103
- import requests
104
 
105
  def inference(img):
106
  out = face2hero(img, 400)
@@ -112,4 +98,15 @@ description = "Style transfer a face into one of a \"Comics hero\". Upload an im
112
  article = "<hr><p style='text-align: center'>See the <a href='https://github.com/Norod/U-2-Net-StyleTransfer' target='_blank'>Github Repo</a></p><p style='text-align: center'>samples: <img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00001.jpg' alt='Sample00001'/><img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00002.jpg' alt='Sample00002'/><img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00003.jpg' alt='Sample00003'/><img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00004.jpg' alt='Sample00004'/><img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00005.jpg' alt='Sample00005'/></p><p>The \"Comics Hero (U2Net)\" model was trained by <a href='https://linktr.ee/Norod78' target='_blank'>Doron Adler</a></p>"
113
 
114
  examples=[['Example00001.jpg'],['Example00002.jpg'],['Example00003.jpg'],['Example00004.jpg'],['Example00005.jpg'], ['Example00006.jpg']]
115
- gr.Interface(inference, gr.inputs.Image(type="pil",shape=(1024,1024)), [gr.outputs.Image(type="pil"),gr.outputs.Image(type="pil")],title=title,description=description,article=article,examples=examples,enable_queue=True,allow_flagging=False).launch()
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  os.system("pip install dlib")
3
+ os.system("pip install gradio==2.5.3")
4
  import sys
5
  import face_detection
6
  import PIL
7
+ from PIL import Image, ImageOps, ImageFile
8
  import numpy as np
9
 
10
  import torch
 
82
  else:
83
  input = torch.Tensor(aligned_img)
84
  results = model(input)
 
85
  d2 = array_to_image(results[1].detach().numpy())
86
+ output = img_concat_h(array_to_image(aligned_img), d2)
 
 
 
87
  del results
88
 
89
  return output
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  def inference(img):
92
  out = face2hero(img, 400)
 
98
  article = "<hr><p style='text-align: center'>See the <a href='https://github.com/Norod/U-2-Net-StyleTransfer' target='_blank'>Github Repo</a></p><p style='text-align: center'>samples: <img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00001.jpg' alt='Sample00001'/><img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00002.jpg' alt='Sample00002'/><img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00003.jpg' alt='Sample00003'/><img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00004.jpg' alt='Sample00004'/><img src='https://hf.space/gradioiframe/Norod78/ComicsHeroU2Net/file/Sample00005.jpg' alt='Sample00005'/></p><p>The \"Comics Hero (U2Net)\" model was trained by <a href='https://linktr.ee/Norod78' target='_blank'>Doron Adler</a></p>"
99
 
100
  examples=[['Example00001.jpg'],['Example00002.jpg'],['Example00003.jpg'],['Example00004.jpg'],['Example00005.jpg'], ['Example00006.jpg']]
101
+
102
+ gr.Interface(
103
+ inference,
104
+ gr.inputs.Image(type="pil", label="Input"),
105
+ gr.outputs.Image(type="pil", label="Output"),
106
+ title=title,
107
+ description=description,
108
+ article=article,
109
+ examples=examples,
110
+ enable_queue=True,
111
+ allow_flagging=False
112
+ ).launch()