salomonsky commited on
Commit
c31f77a
·
verified ·
1 Parent(s): 2d0358d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -22
app.py CHANGED
@@ -113,22 +113,25 @@ def save_prompt(prompt):
113
  st.success("Prompt guardado.")
114
 
115
  def generate_variations(prompt, num_variants, use_enhanced):
116
- instructions = [
117
- "With this words, create a photorealistic description for a detailed txt2img prompt in English in 200 characters maximum",
118
- "With this idea, write a creative, realistic, and detailed text-to-image prompt in English in 200 characters maximum",
119
- "With this text, generate a descriptive and True to life txt2img prompt in English in 200 characters maximum",
120
- "With my idea, describe a photorealistic scene with detailed illumination for a txt2img prompt in English in 200 characters maximum",
121
- "With this concept, give a realistic, elegant txt2img prompt in English, emphasizing photorealism in 200 characters maximum",
122
- "With this perspective, conform a visually dynamic and hyperrealistic txt2img prompt in English in 200 characters maximum",
123
- "With this inspiration, realize a cinematic txt2img prompt in English with hyperrealistic elements in 200 characters maximum",
124
- "With my idea, make a lifelike and txt2img prompt in English, focusing on photorealistic depth in 200 characters maximum"
125
- ]
126
- prompts = set()
127
- while len(prompts) < num_variants:
128
- instruction = random.choice(instructions)
129
- enhanced_prompt = f"{prompt}"
130
- prompts.add(enhanced_prompt)
131
- return list(prompts)
 
 
 
132
 
133
  def get_prompt_for_image(image_name):
134
  prompts = {}
@@ -203,17 +206,18 @@ def main():
203
  prompt_enhance = st.sidebar.checkbox("Mejorar Prompt", True)
204
  num_variants = st.sidebar.slider("Número de imágenes", 1, 8, 8)
205
  width, height = (720, 1280) if format_option == "9:16" else (1280, 720) if format_option == "16:9" else (1280, 1280)
206
- if prompt_enhance and prompt:
207
- prompts = generate_variations(prompt, num_variants=num_variants, use_enhanced=True)
208
- else:
209
- prompts = [prompt] * num_variants
210
- if st.sidebar.button("Generar Imágenes"):
211
- images = gen(prompts, width, height, model_option, num_variants)
212
  if generated_image_path and upscale_checkbox:
213
  upscale_factor = st.sidebar.slider("Factor de Escalado", 1, 4, 2)
214
  improved_image = get_upscale_finegrain(prompt, generated_image_path, upscale_factor)
215
  if improved_image:
216
  st.image(improved_image, caption="Imagen Escalada", use_column_width=True)
 
217
  upload_image_to_gallery()
218
  display_gallery()
219
 
 
113
  st.success("Prompt guardado.")
114
 
115
  def generate_variations(prompt, num_variants, use_enhanced):
116
+ if use_enhanced:
117
+ instructions = [
118
+ "With this words, create a photorealistic description for a detailed txt2img prompt in English in 200 characters maximum",
119
+ "With this idea, write a creative, realistic, and detailed text-to-image prompt in English in 200 characters maximum",
120
+ "With this text, generate a descriptive and True to life txt2img prompt in English in 200 characters maximum",
121
+ "With my idea, describe a photorealistic scene with detailed illumination for a txt2img prompt in English in 200 characters maximum",
122
+ "With this concept, give a realistic, elegant txt2img prompt in English, emphasizing photorealism in 200 characters maximum",
123
+ "With this perspective, conform a visually dynamic and hyperrealistic txt2img prompt in English in 200 characters maximum",
124
+ "With this inspiration, realize a cinematic txt2img prompt in English with hyperrealistic elements in 200 characters maximum",
125
+ "With my idea, make a lifelike and txt2img prompt in English, focusing on photorealistic depth in 200 characters maximum"
126
+ ]
127
+ prompts = set()
128
+ while len(prompts) < num_variants:
129
+ instruction = random.choice(instructions)
130
+ enhanced_prompt = f"{instruction}: {prompt}"
131
+ prompts.add(enhanced_prompt)
132
+ return list(prompts)
133
+ else:
134
+ return [prompt] * num_variants
135
 
136
  def get_prompt_for_image(image_name):
137
  prompts = {}
 
206
  prompt_enhance = st.sidebar.checkbox("Mejorar Prompt", True)
207
  num_variants = st.sidebar.slider("Número de imágenes", 1, 8, 8)
208
  width, height = (720, 1280) if format_option == "9:16" else (1280, 720) if format_option == "16:9" else (1280, 1280)
209
+
210
+ if prompt:
211
+ prompts = generate_variations(prompt, num_variants=num_variants, use_enhanced=prompt_enhance)
212
+ if st.sidebar.button("Generar Imágenes"):
213
+ images = gen(prompts, width, height, model_option, num_variants)
214
+
215
  if generated_image_path and upscale_checkbox:
216
  upscale_factor = st.sidebar.slider("Factor de Escalado", 1, 4, 2)
217
  improved_image = get_upscale_finegrain(prompt, generated_image_path, upscale_factor)
218
  if improved_image:
219
  st.image(improved_image, caption="Imagen Escalada", use_column_width=True)
220
+
221
  upload_image_to_gallery()
222
  display_gallery()
223