arjunyonjan commited on
Commit
189b7ed
·
verified ·
1 Parent(s): 6cd2f04

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -34,7 +34,12 @@ def swap_face(source_img, target_img):
34
  except Exception:
35
  app.prepare(ctx_id=-1, det_size=(640, 640))
36
  import insightface.model_zoo
37
- swapper = insightface.model_zoo.get_model("inswapper_128.onnx", download=True)
 
 
 
 
 
38
  s_faces = app.get(src)
39
  t_faces = app.get(tgt)
40
  if len(s_faces) == 0 or len(t_faces) == 0:
 
34
  except Exception:
35
  app.prepare(ctx_id=-1, det_size=(640, 640))
36
  import insightface.model_zoo
37
+ import os as _os, urllib.request as _url
38
+ _mdir="/tmp/ifmodels"; _os.makedirs(_mdir, exist_ok=True)
39
+ _sp=_os.path.join(_mdir,"inswapper_128.onnx")
40
+ if not _os.path.exists(_sp):
41
+ _url.urlretrieve("https://github.com/deepinsight/insightface/releases/download/v0.7/inswapper_128.onnx", _sp)
42
+ swapper = insightface.model_zoo.get_model(_sp)
43
  s_faces = app.get(src)
44
  t_faces = app.get(tgt)
45
  if len(s_faces) == 0 or len(t_faces) == 0: