Spaces:
Running
Running
prithivMLmods
commited on
Commit
•
33e319e
1
Parent(s):
eeac1ae
Delete app.py
Browse files
app.py
DELETED
@@ -1,73 +0,0 @@
|
|
1 |
-
# -* coding:UTF-8 -*
|
2 |
-
# !/usr/bin/env python
|
3 |
-
import spaces
|
4 |
-
import numpy as np
|
5 |
-
import gradio as gr
|
6 |
-
import roop.globals
|
7 |
-
from roop.core import (
|
8 |
-
start,
|
9 |
-
decode_execution_providers,
|
10 |
-
suggest_max_memory,
|
11 |
-
suggest_execution_threads,
|
12 |
-
)
|
13 |
-
from roop.processors.frame.core import get_frame_processors_modules
|
14 |
-
from roop.utilities import normalize_output_path
|
15 |
-
import os
|
16 |
-
from PIL import Image
|
17 |
-
|
18 |
-
@spaces.GPU()
|
19 |
-
def swap_face(source_file, target_file,doFaceEnhancer):
|
20 |
-
|
21 |
-
source_path = "input.jpg"
|
22 |
-
target_path = "target.jpg"
|
23 |
-
|
24 |
-
source_image = Image.fromarray(source_file)
|
25 |
-
source_image.save(source_path)
|
26 |
-
target_image = Image.fromarray(target_file)
|
27 |
-
target_image.save(target_path)
|
28 |
-
|
29 |
-
print("source_path: ", source_path)
|
30 |
-
print("target_path: ", target_path)
|
31 |
-
|
32 |
-
roop.globals.source_path = source_path
|
33 |
-
roop.globals.target_path = target_path
|
34 |
-
output_path = "output.jpg"
|
35 |
-
roop.globals.output_path = normalize_output_path(
|
36 |
-
roop.globals.source_path, roop.globals.target_path, output_path
|
37 |
-
)
|
38 |
-
if doFaceEnhancer == True:
|
39 |
-
roop.globals.frame_processors = ["face_swapper","face_enhancer"]
|
40 |
-
else:
|
41 |
-
roop.globals.frame_processors = ["face_swapper"]
|
42 |
-
roop.globals.headless = True
|
43 |
-
roop.globals.keep_fps = True
|
44 |
-
roop.globals.keep_audio = True
|
45 |
-
roop.globals.keep_frames = False
|
46 |
-
roop.globals.many_faces = False
|
47 |
-
roop.globals.video_encoder = "libx264"
|
48 |
-
roop.globals.video_quality = 18
|
49 |
-
roop.globals.max_memory = suggest_max_memory()
|
50 |
-
roop.globals.execution_providers = decode_execution_providers(["cuda"])
|
51 |
-
roop.globals.execution_threads = suggest_execution_threads()
|
52 |
-
|
53 |
-
print(
|
54 |
-
"start process",
|
55 |
-
roop.globals.source_path,
|
56 |
-
roop.globals.target_path,
|
57 |
-
roop.globals.output_path,
|
58 |
-
)
|
59 |
-
|
60 |
-
for frame_processor in get_frame_processors_modules(
|
61 |
-
roop.globals.frame_processors
|
62 |
-
):
|
63 |
-
if not frame_processor.pre_check():
|
64 |
-
return
|
65 |
-
|
66 |
-
start()
|
67 |
-
return output_path
|
68 |
-
|
69 |
-
|
70 |
-
app = gr.Interface(
|
71 |
-
fn=swap_face, inputs=[gr.Image(), gr.Image(),gr.Checkbox(label="face_enhancer?", info="do face enhancer?", value=True)], outputs="image", theme="prithivMLmods/Minecraft-Theme"
|
72 |
-
)
|
73 |
-
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|