Spaces:
Running
Running
Raise 500
Browse files- funciones.py +17 -11
- herramientas.py +2 -2
funciones.py
CHANGED
@@ -1,12 +1,14 @@
|
|
1 |
import io
|
2 |
import globales
|
3 |
import espacios
|
|
|
4 |
import herramientas
|
5 |
import gradio_client
|
6 |
-
from huggingface_hub import InferenceClient
|
7 |
import conexion_firebase
|
8 |
-
import
|
9 |
-
import
|
|
|
|
|
10 |
|
11 |
def genera_platillo_gpu(platillo):
|
12 |
|
@@ -50,21 +52,22 @@ def genera_platillo_gpu(platillo):
|
|
50 |
print("Excepción: ", e)
|
51 |
# Opción para regresar imagen genérica. (ya no porque se envía desde backend.)
|
52 |
# return "default.png"
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
56 |
|
57 |
|
58 |
def genera_platillo_inference(platillo):
|
59 |
|
60 |
|
61 |
-
modelo_actual = conexion_firebase.obtenDato('nowme',
|
62 |
modelo = modelo_actual
|
63 |
|
64 |
print("Modelo:", modelo)
|
65 |
|
66 |
#Elegir proveedor de inferencia
|
67 |
-
creditos_restantes_inference = conexion_firebase.obtenDato('nowme',
|
68 |
#creditos_restantes_inference = 5000
|
69 |
|
70 |
#print("Los créditos restantes de hf-inference que tienes son: ", creditos_restantes_inference)
|
@@ -101,11 +104,14 @@ def genera_platillo_inference(platillo):
|
|
101 |
modelo=globales.inferencia_backup
|
102 |
#Escribe en txt el nuevo modelo.
|
103 |
herramientas.modificaModeloActual(modelo)
|
104 |
-
|
|
|
|
|
|
|
|
|
105 |
|
106 |
img_io = io.BytesIO()
|
107 |
image.save(img_io, "PNG")
|
108 |
img_io.seek(0)
|
109 |
print("Platillo generado:", platillo)
|
110 |
-
return img_io
|
111 |
-
|
|
|
1 |
import io
|
2 |
import globales
|
3 |
import espacios
|
4 |
+
import random
|
5 |
import herramientas
|
6 |
import gradio_client
|
|
|
7 |
import conexion_firebase
|
8 |
+
from fastapi import HTTPException, status
|
9 |
+
from huggingface_hub import InferenceClient
|
10 |
+
|
11 |
+
servidor = globales.servidor
|
12 |
|
13 |
def genera_platillo_gpu(platillo):
|
14 |
|
|
|
52 |
print("Excepción: ", e)
|
53 |
# Opción para regresar imagen genérica. (ya no porque se envía desde backend.)
|
54 |
# return "default.png"
|
55 |
+
raise HTTPException(
|
56 |
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
57 |
+
detail=e
|
58 |
+
)
|
59 |
|
60 |
|
61 |
def genera_platillo_inference(platillo):
|
62 |
|
63 |
|
64 |
+
modelo_actual = conexion_firebase.obtenDato('nowme', servidor, 'modelo_actual')
|
65 |
modelo = modelo_actual
|
66 |
|
67 |
print("Modelo:", modelo)
|
68 |
|
69 |
#Elegir proveedor de inferencia
|
70 |
+
creditos_restantes_inference = conexion_firebase.obtenDato('nowme', servidor, 'inferencias')
|
71 |
#creditos_restantes_inference = 5000
|
72 |
|
73 |
#print("Los créditos restantes de hf-inference que tienes son: ", creditos_restantes_inference)
|
|
|
104 |
modelo=globales.inferencia_backup
|
105 |
#Escribe en txt el nuevo modelo.
|
106 |
herramientas.modificaModeloActual(modelo)
|
107 |
+
print(f"Error: {e}")
|
108 |
+
raise HTTPException(
|
109 |
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
110 |
+
detail=e
|
111 |
+
)
|
112 |
|
113 |
img_io = io.BytesIO()
|
114 |
image.save(img_io, "PNG")
|
115 |
img_io.seek(0)
|
116 |
print("Platillo generado:", platillo)
|
117 |
+
return img_io
|
|
herramientas.py
CHANGED
@@ -33,7 +33,7 @@ def obtenSegundosDisponiblesInference():
|
|
33 |
# renuevaModeloPrincipal()
|
34 |
|
35 |
#Finalmente obten los segundos disponibles después de las operaciones.
|
36 |
-
return conexion_firebase.obtenDato('nowme', servidor, '
|
37 |
|
38 |
|
39 |
def renuevaSegundosDisponibles():
|
@@ -74,7 +74,7 @@ def restaSegundosInference(cuantos_segundos):
|
|
74 |
# Restar los segundos
|
75 |
nuevos_segundos_disponibles = segundos_disponibles - cuantos_segundos
|
76 |
print("Segundos disponibles ahora en restaSegundosInference: ", nuevos_segundos_disponibles)
|
77 |
-
conexion_firebase.editaDato('nowme', servidor, '
|
78 |
|
79 |
def modificaModeloActual(nuevo_modelo):
|
80 |
"""
|
|
|
33 |
# renuevaModeloPrincipal()
|
34 |
|
35 |
#Finalmente obten los segundos disponibles después de las operaciones.
|
36 |
+
return conexion_firebase.obtenDato('nowme', servidor, 'inferencias')
|
37 |
|
38 |
|
39 |
def renuevaSegundosDisponibles():
|
|
|
74 |
# Restar los segundos
|
75 |
nuevos_segundos_disponibles = segundos_disponibles - cuantos_segundos
|
76 |
print("Segundos disponibles ahora en restaSegundosInference: ", nuevos_segundos_disponibles)
|
77 |
+
conexion_firebase.editaDato('nowme', servidor, 'inferencias', nuevos_segundos_disponibles)
|
78 |
|
79 |
def modificaModeloActual(nuevo_modelo):
|
80 |
"""
|