Spaces:
Running
Running
Prompt in english
Browse files- autenticacion.py +8 -14
- funciones.py +0 -1
- globales.py +6 -8
- herramientas.py +1 -3
autenticacion.py
CHANGED
@@ -3,27 +3,21 @@ import socket
|
|
3 |
|
4 |
def defineAmbiente():
|
5 |
if local_check():
|
6 |
-
print("
|
7 |
-
import bridges
|
8 |
-
#Acceso a HF
|
9 |
-
|
10 |
-
servidor = "moibe" #o sosa, depende de donde deduciras los segundos cuando pruebas en local.
|
11 |
-
#Acceso a Firebase
|
12 |
-
# Use the application default credentials.
|
13 |
else:
|
14 |
-
print("
|
15 |
-
#Acceso a HF
|
16 |
-
llave = os.getenv("llave")
|
17 |
servidor = os.getenv("servidor")
|
18 |
print("El servidor remoto es: ", servidor)
|
19 |
return llave, servidor
|
20 |
|
21 |
-
def local_check():
|
22 |
-
|
23 |
hostname = socket.gethostname()
|
24 |
#r-moibe-nowme
|
25 |
-
print("
|
26 |
-
|
27 |
#Estoy usando el nombre de la app para identificar que estoy corriendola en HF.
|
28 |
if "-nowme" in hostname:
|
29 |
print("Ejecutando api en el servidor.")
|
|
|
3 |
|
4 |
def defineAmbiente():
|
5 |
if local_check():
|
6 |
+
print("Entorno Local...")
|
7 |
+
import bridges
|
8 |
+
llave = bridges.llave #Acceso a HF
|
9 |
+
servidor = "moibe" #o Sosa Jhons, depende de donde deduciras los segundos cuando pruebas en local.
|
|
|
|
|
|
|
10 |
else:
|
11 |
+
print("Entorno remoto listo...")
|
12 |
+
llave = os.getenv("llave") #Acceso a HF
|
|
|
13 |
servidor = os.getenv("servidor")
|
14 |
print("El servidor remoto es: ", servidor)
|
15 |
return llave, servidor
|
16 |
|
17 |
+
def local_check():
|
|
|
18 |
hostname = socket.gethostname()
|
19 |
#r-moibe-nowme
|
20 |
+
print("Hostname: ", hostname)
|
|
|
21 |
#Estoy usando el nombre de la app para identificar que estoy corriendola en HF.
|
22 |
if "-nowme" in hostname:
|
23 |
print("Ejecutando api en el servidor.")
|
funciones.py
CHANGED
@@ -34,7 +34,6 @@ def genera_platillo_gpu(platillo):
|
|
34 |
herramientas.restaSegundosGPU(globales.work_cost)
|
35 |
|
36 |
print("Platillo generado:", platillo)
|
37 |
-
print("Resultado regresado en result[0] es: ", result[0])
|
38 |
return result[0]
|
39 |
|
40 |
except Exception as e:
|
|
|
34 |
herramientas.restaSegundosGPU(globales.work_cost)
|
35 |
|
36 |
print("Platillo generado:", platillo)
|
|
|
37 |
return result[0]
|
38 |
|
39 |
except Exception as e:
|
globales.py
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
import autenticacion
|
|
|
2 |
|
3 |
-
previo = "Una fotografía de un plato blanco con "
|
|
|
4 |
llave, servidor = autenticacion.defineAmbiente()
|
5 |
-
|
6 |
espacio = "black-forest-labs/FLUX.1-schnell"
|
7 |
#espacio = "black-forest-labs/FLUX.1-dev"
|
8 |
-
inferencia = "black-forest-labs/FLUX.1-dev"
|
9 |
-
inferencia_backup = "black-forest-labs/FLUX.1-schnell"
|
10 |
-
|
11 |
proveedor = "hf-inference" #falai
|
12 |
-
|
13 |
-
work_cost = 6
|
14 |
-
|
15 |
quota = 300
|
|
|
1 |
import autenticacion
|
2 |
+
version = "0.0.0"
|
3 |
|
4 |
+
#previo = "Una fotografía de un plato blanco con "
|
5 |
+
previo = "A photograph of a white plate with "
|
6 |
llave, servidor = autenticacion.defineAmbiente()
|
|
|
7 |
espacio = "black-forest-labs/FLUX.1-schnell"
|
8 |
#espacio = "black-forest-labs/FLUX.1-dev"
|
9 |
+
#inferencia = "black-forest-labs/FLUX.1-dev"
|
10 |
+
#inferencia_backup = "black-forest-labs/FLUX.1-schnell"
|
|
|
11 |
proveedor = "hf-inference" #falai
|
12 |
+
work_cost = 6 #Los segundos que cuesta la generación de una imagen, para control de la capa gratuita.
|
|
|
|
|
13 |
quota = 300
|
herramientas.py
CHANGED
@@ -69,6 +69,7 @@ def restaSegundosGPU(cuantos_segundos):
|
|
69 |
|
70 |
# Restar los segundos
|
71 |
nuevos_segundos_disponibles = segundos_disponibles - cuantos_segundos
|
|
|
72 |
conexion_firebase.editaDato('nowme', 'huggingface', segundos, nuevos_segundos_disponibles)
|
73 |
|
74 |
def modificaModeloActual(nuevo_modelo):
|
@@ -127,13 +128,10 @@ def esDiaSiguiente():
|
|
127 |
|
128 |
#fecha_actual_dt = datetime.fromtimestamp(int(time.time())) #Timestamp actual.
|
129 |
fecha_actual_dt = datetime.fromtimestamp(int(time.time()))
|
130 |
-
|
131 |
|
132 |
# Extraer solo la fecha de los objetos datetime
|
133 |
fecha_registro = fecha_registro_dt.date()
|
134 |
fecha_actual = fecha_actual_dt.date()
|
135 |
-
|
136 |
-
print(f"Estoy comparando fecha registro {fecha_registro} con fecha actual {fecha_actual}...")
|
137 |
|
138 |
# Verificar si las fechas son diferentes
|
139 |
return fecha_actual > fecha_registro
|
|
|
69 |
|
70 |
# Restar los segundos
|
71 |
nuevos_segundos_disponibles = segundos_disponibles - cuantos_segundos
|
72 |
+
print("Segundos disponibles ahora.")
|
73 |
conexion_firebase.editaDato('nowme', 'huggingface', segundos, nuevos_segundos_disponibles)
|
74 |
|
75 |
def modificaModeloActual(nuevo_modelo):
|
|
|
128 |
|
129 |
#fecha_actual_dt = datetime.fromtimestamp(int(time.time())) #Timestamp actual.
|
130 |
fecha_actual_dt = datetime.fromtimestamp(int(time.time()))
|
|
|
131 |
|
132 |
# Extraer solo la fecha de los objetos datetime
|
133 |
fecha_registro = fecha_registro_dt.date()
|
134 |
fecha_actual = fecha_actual_dt.date()
|
|
|
|
|
135 |
|
136 |
# Verificar si las fechas son diferentes
|
137 |
return fecha_actual > fecha_registro
|