jjeamin commited on
Commit
f60da0f
1 Parent(s): b82b107

Update face alignment

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -1,12 +1,10 @@
1
  import os
2
- from huggingface_hub import hf_hub_download
3
- os.system("pip -qq install facenet_pytorch")
4
- from facenet_pytorch import MTCNN
5
- from torchvision import transforms
6
  import torch, PIL
7
  import gradio as gr
8
  import torch
9
  from utils import align_face
 
 
10
 
11
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
12
 
@@ -35,9 +33,6 @@ def tensor2im(var):
35
  return var.mul(t_stds).add(t_means).mul(255.).clamp(0,255).permute(1,2,0)
36
 
37
  def proc_pil_img(input_image):
38
- # input_image = PIL
39
- input_image = align_face(input_image, output_size=image_size, transform_size=transform_size)
40
-
41
  if 'cuda' in device:
42
  transformed_image = img_transforms(input_image)[None,...].cuda().half()
43
  else:
@@ -51,6 +46,7 @@ def proc_pil_img(input_image):
51
  return output_image
52
 
53
  def process(im):
 
54
  res = proc_pil_img(im)
55
  return res
56
 
 
1
  import os
 
 
 
 
2
  import torch, PIL
3
  import gradio as gr
4
  import torch
5
  from utils import align_face
6
+ from torchvision import transforms
7
+ from huggingface_hub import hf_hub_download
8
 
9
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
10
 
 
33
  return var.mul(t_stds).add(t_means).mul(255.).clamp(0,255).permute(1,2,0)
34
 
35
  def proc_pil_img(input_image):
 
 
 
36
  if 'cuda' in device:
37
  transformed_image = img_transforms(input_image)[None,...].cuda().half()
38
  else:
 
46
  return output_image
47
 
48
  def process(im):
49
+ im = align_face(im, output_size=image_size, transform_size=transform_size)
50
  res = proc_pil_img(im)
51
  return res
52