Spaces:
Running
Running
Commit Β·
80d0f2c
1
Parent(s): fd32b5e
Fix: remove type hints from callbacks to fix gradio_client schema bug
Browse files
app.py
CHANGED
|
@@ -12,7 +12,6 @@ Tabs
|
|
| 12 |
import cv2
|
| 13 |
import numpy as np
|
| 14 |
import gradio as gr
|
| 15 |
-
from PIL import Image
|
| 16 |
|
| 17 |
from utils.image_utils import pil_to_bgr, bgr_to_pil
|
| 18 |
|
|
@@ -39,11 +38,7 @@ def _get_body_swapper():
|
|
| 39 |
|
| 40 |
# ββ Processing functions βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 41 |
|
| 42 |
-
def face_swap_image(
|
| 43 |
-
source_img: Image.Image,
|
| 44 |
-
target_img: Image.Image,
|
| 45 |
-
enhance: bool,
|
| 46 |
-
) -> tuple[Image.Image | None, str]:
|
| 47 |
if source_img is None or target_img is None:
|
| 48 |
return None, "Please upload both a source and a target image."
|
| 49 |
|
|
@@ -55,11 +50,7 @@ def face_swap_image(
|
|
| 55 |
return (bgr_to_pil(result) if result is not None else None), msg
|
| 56 |
|
| 57 |
|
| 58 |
-
def body_swap_image(
|
| 59 |
-
source_img: Image.Image,
|
| 60 |
-
target_img: Image.Image,
|
| 61 |
-
blend_strength: float,
|
| 62 |
-
) -> tuple[Image.Image | None, str]:
|
| 63 |
if source_img is None or target_img is None:
|
| 64 |
return None, "Please upload both a source and a target image."
|
| 65 |
|
|
@@ -71,12 +62,7 @@ def body_swap_image(
|
|
| 71 |
return (bgr_to_pil(result) if result is not None else None), msg
|
| 72 |
|
| 73 |
|
| 74 |
-
def face_swap_video(
|
| 75 |
-
source_img: Image.Image,
|
| 76 |
-
target_video: str,
|
| 77 |
-
enhance: bool,
|
| 78 |
-
progress=gr.Progress(),
|
| 79 |
-
) -> tuple[str | None, str]:
|
| 80 |
if source_img is None or target_video is None:
|
| 81 |
return None, "Please upload a source face image and a target video."
|
| 82 |
|
|
@@ -92,12 +78,7 @@ def face_swap_video(
|
|
| 92 |
return output_path, msg
|
| 93 |
|
| 94 |
|
| 95 |
-
def body_swap_video(
|
| 96 |
-
source_img: Image.Image,
|
| 97 |
-
target_video: str,
|
| 98 |
-
blend_strength: float,
|
| 99 |
-
progress=gr.Progress(),
|
| 100 |
-
) -> tuple[str | None, str]:
|
| 101 |
if source_img is None or target_video is None:
|
| 102 |
return None, "Please upload a source body image and a target video."
|
| 103 |
|
|
|
|
| 12 |
import cv2
|
| 13 |
import numpy as np
|
| 14 |
import gradio as gr
|
|
|
|
| 15 |
|
| 16 |
from utils.image_utils import pil_to_bgr, bgr_to_pil
|
| 17 |
|
|
|
|
| 38 |
|
| 39 |
# ββ Processing functions βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 40 |
|
| 41 |
+
def face_swap_image(source_img, target_img, enhance):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
if source_img is None or target_img is None:
|
| 43 |
return None, "Please upload both a source and a target image."
|
| 44 |
|
|
|
|
| 50 |
return (bgr_to_pil(result) if result is not None else None), msg
|
| 51 |
|
| 52 |
|
| 53 |
+
def body_swap_image(source_img, target_img, blend_strength):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
if source_img is None or target_img is None:
|
| 55 |
return None, "Please upload both a source and a target image."
|
| 56 |
|
|
|
|
| 62 |
return (bgr_to_pil(result) if result is not None else None), msg
|
| 63 |
|
| 64 |
|
| 65 |
+
def face_swap_video(source_img, target_video, enhance, progress=gr.Progress()):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
if source_img is None or target_video is None:
|
| 67 |
return None, "Please upload a source face image and a target video."
|
| 68 |
|
|
|
|
| 78 |
return output_path, msg
|
| 79 |
|
| 80 |
|
| 81 |
+
def body_swap_video(source_img, target_video, blend_strength, progress=gr.Progress()):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
if source_img is None or target_video is None:
|
| 83 |
return None, "Please upload a source body image and a target video."
|
| 84 |
|