Spaces:
Running
Running
Upload 2 files
Browse files- app.py +27 -0
- requirements.txt +6 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
import numpy as np
|
4 |
+
import cv2
|
5 |
+
import os
|
6 |
+
import torch
|
7 |
+
import torchvision.transforms as transforms
|
8 |
+
from SimSwap.inference import run_faceswap # Supuesto m贸dulo que contiene la l贸gica real
|
9 |
+
|
10 |
+
def simswap_api(base_image, face_image):
|
11 |
+
# Simulaci贸n de flujo de SimSwap
|
12 |
+
result = run_faceswap(base_image, face_image)
|
13 |
+
return Image.fromarray(cv2.cvtColor(result, cv2.COLOR_BGR2RGB))
|
14 |
+
|
15 |
+
demo = gr.Interface(
|
16 |
+
fn=simswap_api,
|
17 |
+
inputs=[
|
18 |
+
gr.Image(type="pil", label="Imagen base (cuerpo y fondo)"),
|
19 |
+
gr.Image(type="pil", label="Imagen de rostro (identidad)"),
|
20 |
+
],
|
21 |
+
outputs=gr.Image(type="pil"),
|
22 |
+
title="SimSwap Face Swap",
|
23 |
+
description="Reemplaza el rostro manteniendo el fondo y cuerpo intactos usando SimSwap"
|
24 |
+
)
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
torch
|
3 |
+
torchvision
|
4 |
+
Pillow
|
5 |
+
opencv-python
|
6 |
+
numpy
|