Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,54 +1,43 @@
|
|
| 1 |
-
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
def obtener_ruta_limpia(archivo):
|
| 6 |
-
"""Extrae de forma segura la ruta del archivo en Gradio 6"""
|
| 7 |
-
if hasattr(archivo, 'path'):
|
| 8 |
-
return archivo.path
|
| 9 |
-
if isinstance(archivo, dict) and 'path' in archivo:
|
| 10 |
-
return archivo['path']
|
| 11 |
-
if isinstance(archivo, str):
|
| 12 |
-
return archivo
|
| 13 |
-
return None
|
| 14 |
|
| 15 |
def procesar_movimiento(imagen_input, video_input):
|
| 16 |
-
|
| 17 |
-
ruta_vid = obtener_ruta_limpia(video_input)
|
| 18 |
-
|
| 19 |
-
if not ruta_img or not ruta_vid:
|
| 20 |
return None, "Error: Por favor, asegúrate de cargar tanto la foto como el video."
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
# --- INTERFAZ GRÁFICA
|
| 50 |
with gr.Blocks() as demo:
|
| 51 |
-
gr.Markdown("# 🎬 Mi Clonador AI Móvil (
|
| 52 |
|
| 53 |
with gr.Tabs():
|
| 54 |
with gr.TabItem("Cargar Archivos"):
|
|
@@ -65,4 +54,4 @@ with gr.Blocks() as demo:
|
|
| 65 |
outputs=[output_vid, output_info]
|
| 66 |
)
|
| 67 |
|
| 68 |
-
demo.launch(
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from gradio_client import Client, handle_file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
def procesar_movimiento(imagen_input, video_input):
|
| 5 |
+
if not imagen_input or not video_input:
|
|
|
|
|
|
|
|
|
|
| 6 |
return None, "Error: Por favor, asegúrate de cargar tanto la foto como el video."
|
| 7 |
|
| 8 |
+
# Lista de servidores públicos de LivePortrait (motores alternativos)
|
| 9 |
+
motores = [
|
| 10 |
+
"KwaiVGI/LivePortrait",
|
| 11 |
+
"innoai/LivePortrait",
|
| 12 |
+
"appl044/LivePortrait"
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
detalles_errores = []
|
| 16 |
+
|
| 17 |
+
# Probar cada motor uno por uno si el anterior está caído o pausado
|
| 18 |
+
for motor in motores:
|
| 19 |
+
try:
|
| 20 |
+
client = Client(motor)
|
| 21 |
+
resultado = client.predict(
|
| 22 |
+
img_input=handle_file(imagen_input),
|
| 23 |
+
driving_video=handle_file(video_input),
|
| 24 |
+
api_name="/predict"
|
| 25 |
+
)
|
| 26 |
+
if resultado:
|
| 27 |
+
return resultado, f"¡Éxito total usando el motor: {motor}!"
|
| 28 |
+
except Exception as e:
|
| 29 |
+
# Si falla (por estar PAUSED o desconectado), guardamos el error y probamos el siguiente
|
| 30 |
+
detalles_errores.append(f"[{motor} no disponible]")
|
| 31 |
+
continue
|
| 32 |
|
| 33 |
+
# Si llega aquí, es porque lamentablemente todos estaban dormidos a la vez
|
| 34 |
+
error_msg = " Todos los motores gratuitos están pausados en Hugging Face en este momento. "
|
| 35 |
+
error_msg += "Detalles: " + " || ".join(detalles_errores)
|
| 36 |
+
return None, error_msg
|
| 37 |
|
| 38 |
+
# --- INTERFAZ GRÁFICA ---
|
| 39 |
with gr.Blocks() as demo:
|
| 40 |
+
gr.Markdown("# 🎬 Mi Clonador AI Móvil (Multimotor)")
|
| 41 |
|
| 42 |
with gr.Tabs():
|
| 43 |
with gr.TabItem("Cargar Archivos"):
|
|
|
|
| 54 |
outputs=[output_vid, output_info]
|
| 55 |
)
|
| 56 |
|
| 57 |
+
demo.launch()
|