Spaces:
Sleeping
Sleeping
Config ini
Browse files- config.ini +15 -0
- funciones.py +13 -10
- globales.py +1 -1
config.ini
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import herramientas
|
| 2 |
+
llave = herramientas.obtenAccesoHF()
|
| 3 |
+
|
| 4 |
+
[hugging_face]
|
| 5 |
+
previo = "Una fotograf铆a de un plato blanco con "
|
| 6 |
+
seconds_available = 1500
|
| 7 |
+
espacio = "black-forest-labs/FLUX.1-schnell"
|
| 8 |
+
inferencia = "black-forest-labs/FLUX.1-dev"
|
| 9 |
+
proveedor = "hf-inference"
|
| 10 |
+
|
| 11 |
+
; config = configparser.ConfigParser()
|
| 12 |
+
; config.read("config.ini")
|
| 13 |
+
|
| 14 |
+
; # Configure JWT settings
|
| 15 |
+
; SECRET_KEY = config["misc-keys"]["secret-jwt"]
|
funciones.py
CHANGED
|
@@ -6,8 +6,6 @@ import globales
|
|
| 6 |
|
| 7 |
def genera_platillo_gpu(platillo):
|
| 8 |
|
| 9 |
-
client = gradio_client.Client(globales.espacio, hf_token=globales.llave)
|
| 10 |
-
|
| 11 |
prompt = globales.previo + platillo
|
| 12 |
|
| 13 |
print("Eso es el prompt final:", prompt)
|
|
@@ -15,12 +13,13 @@ def genera_platillo_gpu(platillo):
|
|
| 15 |
kwargs = {
|
| 16 |
"prompt": prompt,
|
| 17 |
"api_name": "/infer"
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
|
| 21 |
try:
|
|
|
|
|
|
|
| 22 |
result = client.predict(**kwargs
|
| 23 |
-
|
| 24 |
# negative_prompt="",
|
| 25 |
# seed=42,
|
| 26 |
# randomize_seed=True,
|
|
@@ -28,14 +27,14 @@ def genera_platillo_gpu(platillo):
|
|
| 28 |
# height=1024,
|
| 29 |
# guidance_scale=3.5,
|
| 30 |
# num_inference_steps=28,
|
| 31 |
-
# api_name="/infer"
|
| 32 |
)
|
| 33 |
|
| 34 |
return result[0]
|
| 35 |
|
| 36 |
-
except Exception as e:
|
| 37 |
print("Excepci贸n es: ", e)
|
| 38 |
-
return
|
| 39 |
|
| 40 |
|
| 41 |
def genera_platillo_inference(platillo):
|
|
@@ -51,11 +50,12 @@ def genera_platillo_inference(platillo):
|
|
| 51 |
image = client.text_to_image(
|
| 52 |
prompt,
|
| 53 |
model=globales.inferencia,
|
| 54 |
-
#seed=42,
|
| 55 |
#guidance_scale=7.5,
|
| 56 |
#num_inference_steps=50,
|
| 57 |
#width=1024, #El default es 1024 x 1024 y quiz谩 1024*768, el max es 1536.
|
| 58 |
#height=1024 #El l铆mite de replicate es 1024.
|
|
|
|
| 59 |
)
|
| 60 |
|
| 61 |
img_io = io.BytesIO()
|
|
@@ -66,4 +66,7 @@ def genera_platillo_inference(platillo):
|
|
| 66 |
|
| 67 |
except Exception as e:
|
| 68 |
print("Excepci贸n es: ", e)
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def genera_platillo_gpu(platillo):
|
| 8 |
|
|
|
|
|
|
|
| 9 |
prompt = globales.previo + platillo
|
| 10 |
|
| 11 |
print("Eso es el prompt final:", prompt)
|
|
|
|
| 13 |
kwargs = {
|
| 14 |
"prompt": prompt,
|
| 15 |
"api_name": "/infer"
|
| 16 |
+
}
|
|
|
|
| 17 |
|
| 18 |
try:
|
| 19 |
+
|
| 20 |
+
client = gradio_client.Client(globales.espacio, hf_token=globales.llave)
|
| 21 |
result = client.predict(**kwargs
|
| 22 |
+
# prompt=prompt,
|
| 23 |
# negative_prompt="",
|
| 24 |
# seed=42,
|
| 25 |
# randomize_seed=True,
|
|
|
|
| 27 |
# height=1024,
|
| 28 |
# guidance_scale=3.5,
|
| 29 |
# num_inference_steps=28,
|
| 30 |
+
# api_name="/infer"
|
| 31 |
)
|
| 32 |
|
| 33 |
return result[0]
|
| 34 |
|
| 35 |
+
except Exception as e:
|
| 36 |
print("Excepci贸n es: ", e)
|
| 37 |
+
return "default.png"
|
| 38 |
|
| 39 |
|
| 40 |
def genera_platillo_inference(platillo):
|
|
|
|
| 50 |
image = client.text_to_image(
|
| 51 |
prompt,
|
| 52 |
model=globales.inferencia,
|
| 53 |
+
#seed=42,
|
| 54 |
#guidance_scale=7.5,
|
| 55 |
#num_inference_steps=50,
|
| 56 |
#width=1024, #El default es 1024 x 1024 y quiz谩 1024*768, el max es 1536.
|
| 57 |
#height=1024 #El l铆mite de replicate es 1024.
|
| 58 |
+
|
| 59 |
)
|
| 60 |
|
| 61 |
img_io = io.BytesIO()
|
|
|
|
| 66 |
|
| 67 |
except Exception as e:
|
| 68 |
print("Excepci贸n es: ", e)
|
| 69 |
+
with open("default.png", "rb") as default_image_file:
|
| 70 |
+
img_io_default = io.BytesIO(default_image_file.read())
|
| 71 |
+
img_io_default.seek(0)
|
| 72 |
+
return img_io_default
|
globales.py
CHANGED
|
@@ -3,7 +3,7 @@ import herramientas
|
|
| 3 |
previo = "Una fotograf铆a de un plato blanco con "
|
| 4 |
llave = herramientas.obtenAccesoHF()
|
| 5 |
|
| 6 |
-
seconds_available =
|
| 7 |
|
| 8 |
espacio = "black-forest-labs/FLUX.1-schnell"
|
| 9 |
#espacio = "black-forest-labs/FLUX.1-dev"
|
|
|
|
| 3 |
previo = "Una fotograf铆a de un plato blanco con "
|
| 4 |
llave = herramientas.obtenAccesoHF()
|
| 5 |
|
| 6 |
+
seconds_available = 1500
|
| 7 |
|
| 8 |
espacio = "black-forest-labs/FLUX.1-schnell"
|
| 9 |
#espacio = "black-forest-labs/FLUX.1-dev"
|