echen01 commited on
Commit
dd1add1
1 Parent(s): 5c10e4d
Files changed (2) hide show
  1. .gitattributes +2 -1
  2. app.py +8 -5
.gitattributes CHANGED
@@ -32,4 +32,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
- *.tar filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ *.tar filter=lfs diff=lfs merge=lfs -text
36
+ *.dat filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -16,12 +16,15 @@ for year in years:
16
  G, w_avg = utils.load_stylegan2(f"pretrained_models/{year}.pkl", device)
17
  orig_models[year] = { "G": G.eval()}
18
 
19
- transform = transforms.Compose([
20
- transforms.Resize((256, 256)),
21
- transforms.ToTensor(),
22
- transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])])
23
 
24
- # Download human-readable labels for ImageNet.
 
 
 
 
 
 
 
25
  def predict(inp):
26
  #with torch.no_grad():
27
  return inp
 
16
  G, w_avg = utils.load_stylegan2(f"pretrained_models/{year}.pkl", device)
17
  orig_models[year] = { "G": G.eval()}
18
 
 
 
 
 
19
 
20
+ def run_alignment(image_path,idx=None):
21
+ import dlib
22
+ from align_all_parallel import align_face
23
+ predictor = dlib.shape_predictor("pretrained_models/shape_predictor_68_face_landmarks.dat")
24
+ aligned_image = align_face(filepath=image_path, predictor=predictor, idx=idx)
25
+ print("Aligned image has shape: {}".format(aligned_image.size))
26
+ return aligned_image
27
+
28
  def predict(inp):
29
  #with torch.no_grad():
30
  return inp