salomonsky commited on
Commit
c1abc2b
1 Parent(s): 87f81a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -22
app.py CHANGED
@@ -90,6 +90,10 @@ async def improve_prompt(prompt):
90
  formatted_prompt = f"{prompt}: {instruction}"
91
  response = llm_client.text_generation(formatted_prompt, max_new_tokens=200)
92
  improved_text = response['generated_text'].strip() if 'generated_text' in response else response.strip()
 
 
 
 
93
  return improved_text
94
  except Exception as e:
95
  return f"Error mejorando el prompt: {e}"
@@ -99,7 +103,7 @@ def get_storage():
99
  for file in DATA_PATH.glob("*.jpg")
100
  if file.is_file()]
101
  usage = sum([f['size'] for f in files])
102
- return [file["name"] for file in files], f"Uso total: {usage/(1024.0 ** 3):.3f}GB"
103
 
104
  def get_prompts():
105
  prompt_files = [file for file in DATA_PATH.glob("*.txt") if file.is_file()]
@@ -123,24 +127,25 @@ def delete_image(image_path):
123
 
124
  st.set_page_config(layout="wide")
125
  st.title("Generador de Imágenes FLUX")
126
- prompt = st.sidebar.text_input("Descripción de la imagen")
127
- basemodel = st.sidebar.selectbox("Modelo Base", ["black-forest-labs/FLUX.1-schnell", "black-forest-labs/FLUX.1-DEV"])
128
- lora_model = st.sidebar.selectbox("LORA Realismo", ["Shakker-Labs/FLUX.1-dev-LoRA-add-details", "XLabs-AI/flux-RealismLora"])
129
- format_option = st.sidebar.selectbox("Formato", ["9:16", "16:9"])
130
- process_lora = st.sidebar.checkbox("Procesar LORA")
131
- process_upscale = st.sidebar.checkbox("Procesar Escalador")
 
 
 
 
 
 
132
 
133
  if format_option == "9:16":
134
- width = st.sidebar.slider("Ancho", 512, 720, 720, step=8)
135
- height = st.sidebar.slider("Alto", 912, 1280, 1280, step=8)
136
  else:
137
- width = st.sidebar.slider("Ancho", 512, 1280, 1280, step=8)
138
- height = st.sidebar.slider("Alto", 512, 720, 720, step=8)
139
-
140
- upscale_factor = st.sidebar.selectbox("Factor de Escala", [2, 4, 8], index=0)
141
- scales = st.sidebar.slider("Escalado", 1, 20, 10)
142
- steps = st.sidebar.slider("Pasos", 1, 100, 20)
143
- seed = st.sidebar.number_input("Semilla", value=-1)
144
 
145
  if st.sidebar.button("Mejorar prompt"):
146
  improved_prompt = asyncio.run(improve_prompt(prompt))
@@ -149,18 +154,18 @@ if st.sidebar.button("Mejorar prompt"):
149
 
150
  if st.sidebar.button("Generar Imagen"):
151
  with st.spinner("Generando imagen..."):
152
- result = run_gen()
153
- image_paths = result[0]
154
  prompt_file = result[1]
155
-
156
- st.write(f"Image paths: {image_paths}")
157
-
158
  if image_paths:
159
  if Path(image_paths).exists():
160
  st.image(image_paths, caption="Imagen Generada")
161
  else:
162
  st.error("El archivo de imagen no existe.")
163
-
164
  if prompt_file and Path(prompt_file).exists():
165
  prompt_text = Path(prompt_file).read_text()
166
  st.write(f"Prompt utilizado: {prompt_text}")
 
90
  formatted_prompt = f"{prompt}: {instruction}"
91
  response = llm_client.text_generation(formatted_prompt, max_new_tokens=200)
92
  improved_text = response['generated_text'].strip() if 'generated_text' in response else response.strip()
93
+
94
+ if len(improved_text) > 200:
95
+ improved_text = improved_text[:200]
96
+
97
  return improved_text
98
  except Exception as e:
99
  return f"Error mejorando el prompt: {e}"
 
103
  for file in DATA_PATH.glob("*.jpg")
104
  if file.is_file()]
105
  usage = sum([f['size'] for f in files])
106
+ return [file["name"] for f in files], f"Uso total: {usage/(1024.0 ** 3):.3f}GB"
107
 
108
  def get_prompts():
109
  prompt_files = [file for file in DATA_PATH.glob("*.txt") if file.is_file()]
 
127
 
128
  st.set_page_config(layout="wide")
129
  st.title("Generador de Imágenes FLUX")
130
+ prompt = st.sidebar.text_input("Descripción de la imagen", max_chars=200)
131
+
132
+ with st.sidebar.expander("Opciones avanzadas", expanded=False):
133
+ basemodel = st.selectbox("Modelo Base", ["black-forest-labs/FLUX.1-schnell", "black-forest-labs/FLUX.1-DEV"])
134
+ lora_model = st.selectbox("LORA Realismo", ["Shakker-Labs/FLUX.1-dev-LoRA-add-details", "XLabs-AI/flux-RealismLora"])
135
+ format_option = st.selectbox("Formato", ["9:16", "16:9"])
136
+ process_lora = st.checkbox("Procesar LORA")
137
+ process_upscale = st.checkbox("Procesar Escalador")
138
+ upscale_factor = st.selectbox("Factor de Escala", [2, 4, 8], index=0)
139
+ scales = st.slider("Escalado", 1, 20, 10)
140
+ steps = st.slider("Pasos", 1, 100, 20)
141
+ seed = st.number_input("Semilla", value=-1)
142
 
143
  if format_option == "9:16":
144
+ width = 720
145
+ height = 1280
146
  else:
147
+ width = 1280
148
+ height = 720
 
 
 
 
 
149
 
150
  if st.sidebar.button("Mejorar prompt"):
151
  improved_prompt = asyncio.run(improve_prompt(prompt))
 
154
 
155
  if st.sidebar.button("Generar Imagen"):
156
  with st.spinner("Generando imagen..."):
157
+ result = run_gen()
158
+ image_paths = result[0]
159
  prompt_file = result[1]
160
+
161
+ st.write(f"Image paths: {image_paths}")
162
+
163
  if image_paths:
164
  if Path(image_paths).exists():
165
  st.image(image_paths, caption="Imagen Generada")
166
  else:
167
  st.error("El archivo de imagen no existe.")
168
+
169
  if prompt_file and Path(prompt_file).exists():
170
  prompt_text = Path(prompt_file).read_text()
171
  st.write(f"Prompt utilizado: {prompt_text}")