Upload 5 files
Browse files- Unconfirmed 32313.crdownload +7 -0
- app.py +75 -0
- gitattributes +35 -0
- requirements-headless.txt +13 -0
- requirements.txt +18 -0
Unconfirmed 32313.crdownload
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[mypy]
|
| 2 |
+
check_untyped_defs = True
|
| 3 |
+
disallow_any_generics = True
|
| 4 |
+
disallow_untyped_calls = True
|
| 5 |
+
disallow_untyped_defs = True
|
| 6 |
+
ignore_missing_imports = True
|
| 7 |
+
strict_optional = False
|
app.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import roop.globals
|
| 4 |
+
from roop.core import (
|
| 5 |
+
start,
|
| 6 |
+
decode_execution_providers,
|
| 7 |
+
suggest_max_memory,
|
| 8 |
+
suggest_execution_threads,
|
| 9 |
+
)
|
| 10 |
+
from roop.processors.frame.core import get_frame_processors_modules
|
| 11 |
+
from roop.utilities import normalize_output_path
|
| 12 |
+
import os
|
| 13 |
+
from PIL import Image
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def swap_face(source_file, target_file, doFaceEnhancer):
|
| 17 |
+
|
| 18 |
+
source_path = "input.jpg"
|
| 19 |
+
target_path = "target.jpg"
|
| 20 |
+
|
| 21 |
+
source_image = Image.fromarray(source_file)
|
| 22 |
+
source_image.save(source_path)
|
| 23 |
+
target_image = Image.fromarray(target_file)
|
| 24 |
+
target_image.save(target_path)
|
| 25 |
+
|
| 26 |
+
print("source_path: ", source_path)
|
| 27 |
+
print("target_path: ", target_path)
|
| 28 |
+
|
| 29 |
+
roop.globals.source_path = source_path
|
| 30 |
+
roop.globals.target_path = target_path
|
| 31 |
+
output_path = "output.jpg"
|
| 32 |
+
roop.globals.output_path = normalize_output_path(
|
| 33 |
+
roop.globals.source_path, roop.globals.target_path, output_path
|
| 34 |
+
)
|
| 35 |
+
if doFaceEnhancer:
|
| 36 |
+
roop.globals.frame_processors = ["face_swapper", "face_enhancer"]
|
| 37 |
+
else:
|
| 38 |
+
roop.globals.frame_processors = ["face_swapper"]
|
| 39 |
+
roop.globals.headless = True
|
| 40 |
+
roop.globals.keep_fps = True
|
| 41 |
+
roop.globals.keep_audio = True
|
| 42 |
+
roop.globals.keep_frames = False
|
| 43 |
+
roop.globals.many_faces = False
|
| 44 |
+
roop.globals.video_encoder = "libx264"
|
| 45 |
+
roop.globals.video_quality = 18
|
| 46 |
+
roop.globals.max_memory = suggest_max_memory()
|
| 47 |
+
roop.globals.execution_providers = decode_execution_providers(["cuda"])
|
| 48 |
+
roop.globals.execution_threads = suggest_execution_threads()
|
| 49 |
+
|
| 50 |
+
print(
|
| 51 |
+
"start process",
|
| 52 |
+
roop.globals.source_path,
|
| 53 |
+
roop.globals.target_path,
|
| 54 |
+
roop.globals.output_path,
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
for frame_processor in get_frame_processors_modules(
|
| 58 |
+
roop.globals.frame_processors
|
| 59 |
+
):
|
| 60 |
+
if not frame_processor.pre_check():
|
| 61 |
+
return
|
| 62 |
+
|
| 63 |
+
start()
|
| 64 |
+
return output_path
|
| 65 |
+
|
| 66 |
+
app = gr.Blocks(theme="Nymbo/Alyx_Theme")
|
| 67 |
+
|
| 68 |
+
with app:
|
| 69 |
+
gr.Interface(
|
| 70 |
+
fn=swap_face,
|
| 71 |
+
inputs=[gr.Image(), gr.Image(), gr.Checkbox(label="face_enhancer?", info="do face enhancer?")],
|
| 72 |
+
outputs="image"
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
app.launch()
|
gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
requirements-headless.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy==1.24.3
|
| 2 |
+
opencv-python==4.8.0.74
|
| 3 |
+
onnx==1.14.0
|
| 4 |
+
insightface==0.7.3
|
| 5 |
+
psutil==5.9.5
|
| 6 |
+
tk==0.1.0
|
| 7 |
+
customtkinter==5.2.0
|
| 8 |
+
tkinterdnd2==0.3.0
|
| 9 |
+
onnxruntime==1.15.0
|
| 10 |
+
tensorflow==2.13.0
|
| 11 |
+
opennsfw2==0.10.2
|
| 12 |
+
protobuf==4.23.4
|
| 13 |
+
tqdm==4.65.0
|
requirements.txt
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
--extra-index-url https://download.pytorch.org/whl/cu118
|
| 2 |
+
|
| 3 |
+
numpy==1.24.3
|
| 4 |
+
opencv-python==4.8.0.74
|
| 5 |
+
onnx==1.14.0
|
| 6 |
+
insightface==0.7.3
|
| 7 |
+
psutil==5.9.5
|
| 8 |
+
tk==0.1.0
|
| 9 |
+
customtkinter==5.2.0
|
| 10 |
+
tkinterdnd2==0.3.0; sys_platform != 'darwin' and platform_machine != 'arm64'
|
| 11 |
+
tkinterdnd2-universal==1.7.3; sys_platform == 'darwin' and platform_machine == 'arm64'
|
| 12 |
+
pillow==10.0.0
|
| 13 |
+
onnxruntime-gpu==1.15.1; sys_platform != 'darwin'
|
| 14 |
+
tensorflow==2.13.0
|
| 15 |
+
opennsfw2==0.10.2
|
| 16 |
+
protobuf==4.23.4
|
| 17 |
+
tqdm==4.65.0
|
| 18 |
+
gfpgan==1.3.8
|