Ahsen Khaliq commited on
Commit
d9fe6d2
1 Parent(s): 96d399d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -33,15 +33,20 @@ from e4e.models.psp import pSp
33
  from util import *
34
 
35
  @ torch.no_grad()
 
 
 
 
 
 
 
 
 
 
36
 
37
  def projection(img, name, device='cuda'):
38
 
39
- model_path = 'models/e4e_ffhq_encode.pt'
40
- ckpt = torch.load(model_path, map_location='cpu')
41
- opts = ckpt['opts']
42
- opts['checkpoint_path'] = model_path
43
- opts= Namespace(**opts)
44
- net = pSp(opts, device).eval().to(device)
45
  transform = transforms.Compose(
46
  [
47
  transforms.Resize(256),
@@ -57,9 +62,7 @@ def projection(img, name, device='cuda'):
57
  torch.save(result_file, name)
58
  return w_plus[0]
59
 
60
- os.makedirs('models', exist_ok=True)
61
- os.system("gdown https://drive.google.com/uc?id=1jtCg8HQ6RlTmLdnbT2PfW1FJ2AYkWqsK")
62
- os.system("cp e4e_ffhq_encode.pt models/e4e_ffhq_encode.pt")
63
 
64
  os.system("wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2")
65
  os.system("bzip2 -dk shape_predictor_68_face_landmarks.dat.bz2")
 
33
  from util import *
34
 
35
  @ torch.no_grad()
36
+ os.makedirs('models', exist_ok=True)
37
+ os.system("gdown https://drive.google.com/uc?id=1jtCg8HQ6RlTmLdnbT2PfW1FJ2AYkWqsK")
38
+ os.system("cp e4e_ffhq_encode.pt models/e4e_ffhq_encode.pt")
39
+
40
+ model_path = 'models/e4e_ffhq_encode.pt'
41
+ ckpt = torch.load(model_path, map_location='cpu')
42
+ opts = ckpt['opts']
43
+ opts['checkpoint_path'] = model_path
44
+ opts= Namespace(**opts)
45
+ net = pSp(opts, device).eval().to(device)
46
 
47
  def projection(img, name, device='cuda'):
48
 
49
+
 
 
 
 
 
50
  transform = transforms.Compose(
51
  [
52
  transforms.Resize(256),
 
62
  torch.save(result_file, name)
63
  return w_plus[0]
64
 
65
+
 
 
66
 
67
  os.system("wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2")
68
  os.system("bzip2 -dk shape_predictor_68_face_landmarks.dat.bz2")