C2MV commited on
Commit
1452a4c
verified
1 Parent(s): 8b310f1

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -2,21 +2,19 @@
2
  import sys
3
  from pathlib import Path
4
  import os
5
- import subprocess # Para un control m谩s fino sobre los comandos del sistema
6
 
7
- # --- CR脥TICO: L脥NEA PARA FORZAR LA VERSI脫N DE GRADIO ---
8
- # Forzar la desinstalaci贸n de cualquier versi贸n de gradio y gradio_client
9
- # y luego instalar la versi贸n deseada antes de cualquier importaci贸n de gradio.
10
- # Esto es necesario si el entorno de HF Spaces o tu sistema est谩 sobreescribiendo las versiones.
11
- print("INFO: Forzando la instalaci贸n de Gradio 4.29.0...")
12
  try:
13
  # Desinstalar cualquier versi贸n existente de gradio y gradio_client
14
  subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", "gradio", "gradio-client"])
15
- # Instalar la versi贸n espec铆fica deseada
16
- subprocess.check_call([sys.executable, "-m", "pip", "install", "gradio==4.29.0", "gradio-client==1.3.0"]) # 1.3.0 es la client compatible con 4.x
17
- print("INFO: Gradio 4.29.0 instalado correctamente de forma forzada.")
18
  except subprocess.CalledProcessError as e:
19
  print(f"ERROR: Fallo al forzar la instalaci贸n de Gradio 4.29.0: {e}")
 
20
  sys.exit(1)
21
  # --- FIN DE L脥NEA CR脥TICA ---
22
 
@@ -52,7 +50,7 @@ def main():
52
 
53
  print("INFO (app.py): Lanzando la interfaz Gradio localmente...")
54
  try:
55
- demo_instance.launch(debug=True) # Habilitar debug=True para ver m谩s logs de Gradio
56
  except ValueError as ve:
57
  if "shareable link must be created" in str(ve).lower() or "localhost is not accessible" in str(ve).lower():
58
  print("ADVERTENCIA (app.py): Fall贸 el lanzamiento local directo, intentando con share=True...")
 
2
  import sys
3
  from pathlib import Path
4
  import os
5
+ import subprocess
6
 
7
+ # --- CR脥TICO: L脥NEA PARA FORZAR LA VERSI脫N DE GRADIO Y GRADIO-CLIENT CORRECTA ---
8
+ print("INFO: Forzando la instalaci贸n de Gradio 4.29.0 y su cliente compatible...")
 
 
 
9
  try:
10
  # Desinstalar cualquier versi贸n existente de gradio y gradio_client
11
  subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", "gradio", "gradio-client"])
12
+ # Instalar la versi贸n espec铆fica deseada: gradio 4.29.0 necesita gradio-client 0.16.1
13
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "gradio==4.29.0", "gradio-client==0.16.1"])
14
+ print("INFO: Gradio 4.29.0 y gradio-client 0.16.1 instalados correctamente de forma forzada.")
15
  except subprocess.CalledProcessError as e:
16
  print(f"ERROR: Fallo al forzar la instalaci贸n de Gradio 4.29.0: {e}")
17
+ print("Por favor, aseg煤rate de que no hay otras dependencias conflictivas y reintenta despu茅s de una limpieza profunda.")
18
  sys.exit(1)
19
  # --- FIN DE L脥NEA CR脥TICA ---
20
 
 
50
 
51
  print("INFO (app.py): Lanzando la interfaz Gradio localmente...")
52
  try:
53
+ demo_instance.launch(debug=True)
54
  except ValueError as ve:
55
  if "shareable link must be created" in str(ve).lower() or "localhost is not accessible" in str(ve).lower():
56
  print("ADVERTENCIA (app.py): Fall贸 el lanzamiento local directo, intentando con share=True...")