Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
import gradio as gr
|
|
@@ -11,7 +17,6 @@ from huggingface_hub import hf_hub_download
|
|
| 11 |
# --- FORZAR RUTA PARA QUE ENCUENTRE EL M脫DULO ---
|
| 12 |
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
| 13 |
from ip_adapter.ip_adapter_faceid import IPAdapterFaceID
|
| 14 |
-
|
| 15 |
from insightface.app import FaceAnalysis
|
| 16 |
|
| 17 |
# Configuraci贸n
|
|
@@ -23,6 +28,7 @@ print("Descargando/Verificando el modelo IP-Adapter...")
|
|
| 23 |
ip_ckpt = hf_hub_download(repo_id="h94/IP-Adapter-FaceID", filename="ip-adapter-faceid_sd15.bin")
|
| 24 |
|
| 25 |
# Carga de modelos
|
|
|
|
| 26 |
app = FaceAnalysis(name="buffalo_l", providers=['CPUExecutionProvider'])
|
| 27 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
| 28 |
|
|
@@ -42,6 +48,6 @@ def generate(image, prompt):
|
|
| 42 |
)
|
| 43 |
return results[0]
|
| 44 |
|
| 45 |
-
# Lanzar con opciones optimizadas
|
| 46 |
demo = gr.Interface(fn=generate, inputs=[gr.Image(type="pil"), gr.Textbox()], outputs="image")
|
| 47 |
demo.launch(ssr_mode=False)
|
|
|
|
| 1 |
+
# 1. IMPORTACI脫N PREVENTIVA: Si 'spaces' existe, debe ir primero
|
| 2 |
+
try:
|
| 3 |
+
import spaces
|
| 4 |
+
except ImportError:
|
| 5 |
+
pass
|
| 6 |
+
|
| 7 |
import sys
|
| 8 |
import os
|
| 9 |
import gradio as gr
|
|
|
|
| 17 |
# --- FORZAR RUTA PARA QUE ENCUENTRE EL M脫DULO ---
|
| 18 |
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
| 19 |
from ip_adapter.ip_adapter_faceid import IPAdapterFaceID
|
|
|
|
| 20 |
from insightface.app import FaceAnalysis
|
| 21 |
|
| 22 |
# Configuraci贸n
|
|
|
|
| 28 |
ip_ckpt = hf_hub_download(repo_id="h94/IP-Adapter-FaceID", filename="ip-adapter-faceid_sd15.bin")
|
| 29 |
|
| 30 |
# Carga de modelos
|
| 31 |
+
# NOTA: Al usar 'onnxruntime' (versi贸n CPU) en requirements.txt, esto deber铆a ir fluido
|
| 32 |
app = FaceAnalysis(name="buffalo_l", providers=['CPUExecutionProvider'])
|
| 33 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
| 34 |
|
|
|
|
| 48 |
)
|
| 49 |
return results[0]
|
| 50 |
|
| 51 |
+
# Lanzar con opciones optimizadas
|
| 52 |
demo = gr.Interface(fn=generate, inputs=[gr.Image(type="pil"), gr.Textbox()], outputs="image")
|
| 53 |
demo.launch(ssr_mode=False)
|