victorisgeek commited on
Commit
88d76b5
·
verified ·
1 Parent(s): 2576604

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -25,7 +25,7 @@ class Predictor:
25
  )
26
  os.chdir('..')
27
 
28
- """Load the model into memory to make running multiple predictions efficient"""
29
  self.face_swapper = insightface.model_zoo.get_model('models/inswapper_128.onnx',
30
  providers=onnxruntime.get_available_providers())
31
  self.face_enhancer = gfpgan.GFPGANer(model_path='models/GFPGANv1.4.pth', upscale=1)
@@ -38,11 +38,11 @@ class Predictor:
38
  largest = max(analysed, key=lambda x: (x.bbox[2] - x.bbox[0]) * (x.bbox[3] - x.bbox[1]))
39
  return largest
40
  except:
41
- print("No face found")
42
  return None
43
 
44
  def predict(self, input_image_path, swap_image_path):
45
- """Run a single prediction on the model"""
46
  try:
47
  frame = cv2.imread(input_image_path)
48
  face = self.get_face(frame)
@@ -50,7 +50,7 @@ class Predictor:
50
  try:
51
  print(frame.shape, face.shape, source_face.shape)
52
  except:
53
- print("printing shapes failed.")
54
  result = self.face_swapper.get(frame, face, source_face, paste_back=True)
55
 
56
  _, _, result = self.face_enhancer.enhance(
@@ -67,7 +67,7 @@ class Predictor:
67
 
68
  # Instantiate the Predictor class
69
  predictor = Predictor()
70
- title = "Swap Faces Using Our Model!!!"
71
 
72
  # Create Gradio Interface
73
  iface = gr.Interface(
 
25
  )
26
  os.chdir('..')
27
 
28
+ """💎 Load the model into memory to make running multiple predictions efficient"""
29
  self.face_swapper = insightface.model_zoo.get_model('models/inswapper_128.onnx',
30
  providers=onnxruntime.get_available_providers())
31
  self.face_enhancer = gfpgan.GFPGANer(model_path='models/GFPGANv1.4.pth', upscale=1)
 
38
  largest = max(analysed, key=lambda x: (x.bbox[2] - x.bbox[0]) * (x.bbox[3] - x.bbox[1]))
39
  return largest
40
  except:
41
+ print("No face found")
42
  return None
43
 
44
  def predict(self, input_image_path, swap_image_path):
45
+ """🚫 Run a single prediction on the model"""
46
  try:
47
  frame = cv2.imread(input_image_path)
48
  face = self.get_face(frame)
 
50
  try:
51
  print(frame.shape, face.shape, source_face.shape)
52
  except:
53
+ print("💊 printing shapes failed.")
54
  result = self.face_swapper.get(frame, face, source_face, paste_back=True)
55
 
56
  _, _, result = self.face_enhancer.enhance(
 
67
 
68
  # Instantiate the Predictor class
69
  predictor = Predictor()
70
+ title = "# 🧸 Auto adjust Models."
71
 
72
  # Create Gradio Interface
73
  iface = gr.Interface(