Spaces:
Running
Running
Upload 3 files
Browse files- README.md +13 -13
- app.py +42 -0
- requirements.txt +6 -0
README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
---
|
2 |
-
title: Face Morphing
|
3 |
-
emoji: 🐠
|
4 |
-
colorFrom: green
|
5 |
-
colorTo: yellow
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 4.37.2
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
license: mit
|
11 |
-
---
|
12 |
-
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
---
|
2 |
+
title: Face Morphing
|
3 |
+
emoji: 🐠
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 4.37.2
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from datetime import datetime
|
3 |
+
|
4 |
+
from src.face_morp import morph
|
5 |
+
|
6 |
+
def transition(image_files, duration, fps, method, guideline):
|
7 |
+
time = datetime.now().strftime("%d.%m.%Y_%H.%M.%S")
|
8 |
+
output_name = f"output_{time}_{fps}fps.mp4"
|
9 |
+
|
10 |
+
is_dlib = method == "Dlib"
|
11 |
+
|
12 |
+
debug_messages = []
|
13 |
+
|
14 |
+
try:
|
15 |
+
# Apelează funcția morph și prinde mesajele de debug
|
16 |
+
morph(image_files, duration, fps, output_name, guideline, is_dlib)
|
17 |
+
debug_messages.append("Video generation successful")
|
18 |
+
return output_name, "\n".join(debug_messages)
|
19 |
+
|
20 |
+
except Exception as e:
|
21 |
+
error_message = f"Error: {str(e)}"
|
22 |
+
debug_messages.append(error_message)
|
23 |
+
return None, "\n".join(debug_messages)
|
24 |
+
|
25 |
+
if __name__ == "__main__":
|
26 |
+
|
27 |
+
gr.Interface(
|
28 |
+
fn=transition,
|
29 |
+
inputs=[
|
30 |
+
gr.File(file_count="multiple", type="filepath"),
|
31 |
+
gr.Slider(label="Duration (seconds) between images", minimum=1, maximum=10, step=1, value=3),
|
32 |
+
gr.Slider(label="Frames per second (fps)", minimum=1, maximum=60, step=1, value=30),
|
33 |
+
gr.Dropdown(label="Landmarks detection method", choices=["Dlib", "MediaPipe"], value="Dlib"),
|
34 |
+
gr.Checkbox(label="Guideline")
|
35 |
+
],
|
36 |
+
outputs=[gr.Video(), gr.Textbox(label="Debug Messages")],
|
37 |
+
examples=[
|
38 |
+
[["examples/1.png", "examples/2.png", "examples/3.png"], 3, 30, "Dlib", False]
|
39 |
+
],
|
40 |
+
title="Face Morphing",
|
41 |
+
description="Upload multiple images containing faces to create a transition video between them."
|
42 |
+
).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
huggingface_hub==0.22.2
|
2 |
+
opencv-python==4.9.0.80
|
3 |
+
numpy==1.26.4
|
4 |
+
scipy==1.13.0
|
5 |
+
mediapipe==0.10.11
|
6 |
+
tqdm==4.66.4
|