Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,12 +41,12 @@ class Predictor:
|
|
| 41 |
print("No face found")
|
| 42 |
return None
|
| 43 |
|
| 44 |
-
def predict(self, input_image
|
| 45 |
"""Run a single prediction on the model"""
|
| 46 |
try:
|
| 47 |
frame = cv2.imread(input_image.name)
|
| 48 |
face = self.get_face(frame)
|
| 49 |
-
source_face = self.get_face(cv2.imread(
|
| 50 |
try:
|
| 51 |
print(frame.shape, face.shape, source_face.shape)
|
| 52 |
except:
|
|
@@ -60,8 +60,7 @@ class Predictor:
|
|
| 60 |
out_path = tempfile.mkdtemp() + f"/{str(int(time.time()))}.jpg"
|
| 61 |
cv2.imwrite(out_path, result)
|
| 62 |
return out_path
|
| 63 |
-
except Exception as
|
| 64 |
-
print(f"{e}")
|
| 65 |
return None
|
| 66 |
|
| 67 |
|
|
@@ -72,14 +71,10 @@ title = "Swap Faces Using Our Model!!!"
|
|
| 72 |
# Create Gradio Interface
|
| 73 |
iface = gr.Interface(
|
| 74 |
fn=predictor.predict,
|
| 75 |
-
inputs=
|
| 76 |
-
gr.inputs.Image(type="file", label="Target Image"),
|
| 77 |
-
gr.inputs.Image(type="file", label="Swap Image")
|
| 78 |
-
],
|
| 79 |
outputs=gr.outputs.Image(type="file", label="Result"),
|
| 80 |
-
title=
|
| 81 |
-
examples=[["input.jpg", "test.jpg"]])
|
| 82 |
|
| 83 |
|
| 84 |
# Launch the Gradio Interface
|
| 85 |
-
iface.launch()
|
|
|
|
| 41 |
print("No face found")
|
| 42 |
return None
|
| 43 |
|
| 44 |
+
def predict(self, input_image):
|
| 45 |
"""Run a single prediction on the model"""
|
| 46 |
try:
|
| 47 |
frame = cv2.imread(input_image.name)
|
| 48 |
face = self.get_face(frame)
|
| 49 |
+
source_face = self.get_face(cv2.imread("test.jpg"))
|
| 50 |
try:
|
| 51 |
print(frame.shape, face.shape, source_face.shape)
|
| 52 |
except:
|
|
|
|
| 60 |
out_path = tempfile.mkdtemp() + f"/{str(int(time.time()))}.jpg"
|
| 61 |
cv2.imwrite(out_path, result)
|
| 62 |
return out_path
|
| 63 |
+
except Exception as print(f"{e}")
|
|
|
|
| 64 |
return None
|
| 65 |
|
| 66 |
|
|
|
|
| 71 |
# Create Gradio Interface
|
| 72 |
iface = gr.Interface(
|
| 73 |
fn=predictor.predict,
|
| 74 |
+
inputs=gr.inputs.Image(type="file", label="Target Image"),
|
|
|
|
|
|
|
|
|
|
| 75 |
outputs=gr.outputs.Image(type="file", label="Result"),
|
| 76 |
+
title examples=[["input.jpg"]])
|
|
|
|
| 77 |
|
| 78 |
|
| 79 |
# Launch the Gradio Interface
|
| 80 |
+
iface.launch()
|