Add Header Image Theme file
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
# !/usr/bin/env python
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
|
|
5 |
import roop.globals
|
6 |
from roop.core import (
|
7 |
start,
|
@@ -14,7 +15,7 @@ from roop.utilities import normalize_output_path
|
|
14 |
import os
|
15 |
from PIL import Image
|
16 |
|
17 |
-
def swap_face(source_file, target_file, doFaceEnhancer):
|
18 |
source_path = "input.jpg"
|
19 |
target_path = "target.mp4"
|
20 |
|
@@ -27,7 +28,7 @@ def swap_face(source_file, target_file, doFaceEnhancer):
|
|
27 |
|
28 |
print("source_path: ", source_path)
|
29 |
print("target_path: ", target_path)
|
30 |
-
|
31 |
roop.globals.source_path = source_path
|
32 |
roop.globals.target_path = target_path
|
33 |
output_path = "output.mp4"
|
@@ -65,13 +66,20 @@ def swap_face(source_file, target_file, doFaceEnhancer):
|
|
65 |
start()
|
66 |
return output_path
|
67 |
|
68 |
-
with gr.Blocks(
|
|
|
|
|
|
|
69 |
gr.HTML(f'<div style="text-align: center;"><img src="https://www.dpu.ac.th/img/Logo_update_080720.png" width="200"></div>') # Header image
|
70 |
-
|
71 |
gr.Markdown(
|
72 |
"""
|
73 |
## Create DeepFake Video
|
74 |
Upload a source image and a target video, select whether to enable face enhancer, many-face mode and adjust video quality. Then click 'Submit' to swap faces in the video.
|
|
|
|
|
|
|
|
|
75 |
"""
|
76 |
)
|
77 |
|
@@ -80,12 +88,13 @@ with gr.Blocks(title="ROOP DeepFake Video", css=".gradio-container {background-c
|
|
80 |
source_image = gr.Image(label="Source Image", type="numpy")
|
81 |
target_video = gr.Video(label="Target Video")
|
82 |
face_enhancer = gr.Checkbox(label="Enable Face Enhancer")
|
|
|
83 |
submit = gr.Button("Submit")
|
84 |
|
85 |
with gr.Column():
|
86 |
output_video = gr.Video(label="Output Video")
|
87 |
|
88 |
-
submit.click(swap_face, inputs=[source_image, target_video, face_enhancer], outputs=output_video)
|
89 |
|
90 |
|
91 |
demo.launch()
|
|
|
2 |
# !/usr/bin/env python
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
5 |
+
from gradio import themes
|
6 |
import roop.globals
|
7 |
from roop.core import (
|
8 |
start,
|
|
|
15 |
import os
|
16 |
from PIL import Image
|
17 |
|
18 |
+
def swap_face(source_file, target_file, doFaceEnhancer, video_quality):
|
19 |
source_path = "input.jpg"
|
20 |
target_path = "target.mp4"
|
21 |
|
|
|
28 |
|
29 |
print("source_path: ", source_path)
|
30 |
print("target_path: ", target_path)
|
31 |
+
roop.globals.video_quality = video_quality
|
32 |
roop.globals.source_path = source_path
|
33 |
roop.globals.target_path = target_path
|
34 |
output_path = "output.mp4"
|
|
|
66 |
start()
|
67 |
return output_path
|
68 |
|
69 |
+
with gr.Blocks(
|
70 |
+
title="ROOP DeepFake Video",
|
71 |
+
theme=themes.Soft(primary_hue="blue", secondary_hue="blue"), # Apply blue theme
|
72 |
+
) as demo:
|
73 |
gr.HTML(f'<div style="text-align: center;"><img src="https://www.dpu.ac.th/img/Logo_update_080720.png" width="200"></div>') # Header image
|
74 |
+
|
75 |
gr.Markdown(
|
76 |
"""
|
77 |
## Create DeepFake Video
|
78 |
Upload a source image and a target video, select whether to enable face enhancer, many-face mode and adjust video quality. Then click 'Submit' to swap faces in the video.
|
79 |
+
|
80 |
+
**Credits:**
|
81 |
+
|
82 |
+
This study was conducted in the College of Creative Design and Entertainment Technology laboratory at Dhurakij Pundit University by Asst. Prof. Banyapon Poolsawas. The project builds upon the s0md3v/roop repository (https://github.com/s0md3v/roop) for face swapping experiments with video files in the Generative AI and Machine Learning course.
|
83 |
"""
|
84 |
)
|
85 |
|
|
|
88 |
source_image = gr.Image(label="Source Image", type="numpy")
|
89 |
target_video = gr.Video(label="Target Video")
|
90 |
face_enhancer = gr.Checkbox(label="Enable Face Enhancer")
|
91 |
+
video_quality = gr.Slider(minimum=0, maximum=100, step=1, value=18, label="Output Video Quality (0 is Best, 100 is Worst)")
|
92 |
submit = gr.Button("Submit")
|
93 |
|
94 |
with gr.Column():
|
95 |
output_video = gr.Video(label="Output Video")
|
96 |
|
97 |
+
submit.click(swap_face, inputs=[source_image, target_video, face_enhancer, video_quality], outputs=output_video)
|
98 |
|
99 |
|
100 |
demo.launch()
|