Spaces:
Running
Running
salomonsky
commited on
Commit
•
e7fe446
1
Parent(s):
438c833
Update app.py
Browse files
app.py
CHANGED
@@ -88,7 +88,7 @@ async def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_fac
|
|
88 |
|
89 |
async def improve_prompt(prompt):
|
90 |
try:
|
91 |
-
instruction = ("With this idea, describe in English a detailed txt2img prompt in 300
|
92 |
formatted_prompt = f"{instruction}"
|
93 |
response = llm_client.text_generation(formatted_prompt, max_new_tokens=300)
|
94 |
improved_text = response['generated_text'].strip() if 'generated_text' in response else response.strip()
|
@@ -124,12 +124,6 @@ def delete_image(image_path):
|
|
124 |
except Exception as e:
|
125 |
st.error(f"Error al borrar la imagen: {e}")
|
126 |
|
127 |
-
def run_gen():
|
128 |
-
loop = asyncio.new_event_loop()
|
129 |
-
asyncio.set_event_loop(loop)
|
130 |
-
prompt_to_use = st.session_state.get('improved_prompt', prompt)
|
131 |
-
return loop.run_until_complete(gen(prompt_to_use, basemodel, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model, process_lora))
|
132 |
-
|
133 |
st.set_page_config(layout="wide")
|
134 |
st.title("Generador de Imágenes FLUX")
|
135 |
prompt = st.sidebar.text_input("Descripción de la imagen", max_chars=200)
|
@@ -153,13 +147,12 @@ else:
|
|
153 |
height = 720
|
154 |
|
155 |
if st.sidebar.button("Generar Imagen"):
|
156 |
-
with st.spinner("Mejorando
|
157 |
-
improved_prompt =
|
158 |
st.session_state.improved_prompt = improved_prompt
|
159 |
-
st.
|
160 |
-
|
161 |
-
|
162 |
-
result = run_gen()
|
163 |
image_paths = result[0]
|
164 |
prompt_file = result[1]
|
165 |
|
|
|
88 |
|
89 |
async def improve_prompt(prompt):
|
90 |
try:
|
91 |
+
instruction = ("With this idea, describe in English a detailed txt2img prompt in 300 characters at most...")
|
92 |
formatted_prompt = f"{instruction}"
|
93 |
response = llm_client.text_generation(formatted_prompt, max_new_tokens=300)
|
94 |
improved_text = response['generated_text'].strip() if 'generated_text' in response else response.strip()
|
|
|
124 |
except Exception as e:
|
125 |
st.error(f"Error al borrar la imagen: {e}")
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
st.set_page_config(layout="wide")
|
128 |
st.title("Generador de Imágenes FLUX")
|
129 |
prompt = st.sidebar.text_input("Descripción de la imagen", max_chars=200)
|
|
|
147 |
height = 720
|
148 |
|
149 |
if st.sidebar.button("Generar Imagen"):
|
150 |
+
with st.spinner("Mejorando y generando imagen..."):
|
151 |
+
improved_prompt = await improve_prompt(prompt)
|
152 |
st.session_state.improved_prompt = improved_prompt
|
153 |
+
prompt_to_use = st.session_state.get('improved_prompt', prompt)
|
154 |
+
result = await gen(prompt_to_use, basemodel, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model, process_lora)
|
155 |
+
|
|
|
156 |
image_paths = result[0]
|
157 |
prompt_file = result[1]
|
158 |
|