MJaheen commited on
Commit
b67b56b
Β·
1 Parent(s): d98f54b

add debug funcition for monitor results

Browse files
Files changed (1) hide show
  1. src/app.py +92 -0
src/app.py CHANGED
@@ -129,6 +129,76 @@ def load_generator(model_name: str = "Pepe Fine-tuned (LoRA)"):
129
  return PepeGenerator(config)
130
 
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  def get_example_prompts():
133
  """
134
  Return a list of example prompts for inspiration.
@@ -297,6 +367,25 @@ def main():
297
 
298
  # Generate
299
  if generate and prompt:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
  try:
301
  generator = load_generator(selected_model)
302
  processor = ImageProcessor()
@@ -347,6 +436,9 @@ def main():
347
  step_progress.empty()
348
  step_status.empty()
349
 
 
 
 
350
  # Show result
351
  if num_vars == 1:
352
  placeholder.image(image, use_column_width=True)
 
129
  return PepeGenerator(config)
130
 
131
 
132
+ def debug_generation_inputs(timestamp, prompt, style, steps, guidance, seed, model, top_text, bottom_text, num_vars, raw_prompt=False, use_seed=False, add_text=False, font_size=40, font_path=""):
133
+ """
134
+ Debug function to print all generation inputs when 'Generate Meme' is pressed.
135
+
136
+ Args:
137
+ timestamp: Current timestamp when generation started
138
+ prompt: The user's text prompt
139
+ style: Selected style preset
140
+ steps: Number of inference steps
141
+ guidance: Guidance scale value
142
+ seed: Random seed (if used)
143
+ model: Selected model name
144
+ top_text: Top meme text
145
+ bottom_text: Bottom meme text
146
+ num_vars: Number of variations to generate
147
+ raw_prompt: Whether raw prompt mode is enabled
148
+ use_seed: Whether fixed seed is enabled
149
+ add_text: Whether text overlay is enabled
150
+ font_size: Font size for text overlay
151
+ font_path: Path to font file
152
+ """
153
+ print("=" * 80)
154
+ print("🎨 MEME GENERATION DEBUG INFO")
155
+ print("=" * 80)
156
+ print(f"⏰ Timestamp: {timestamp}")
157
+ print(f"πŸ€– Model: {model}")
158
+ print(f"πŸ“ Prompt: {prompt}")
159
+ print(f"🎨 Style: {style}")
160
+ print(f"βš™οΈ Steps: {steps}")
161
+ print(f"🎯 Guidance Scale: {guidance}")
162
+ print(f"πŸ”’ Seed Enabled: {use_seed}")
163
+ if use_seed:
164
+ print(f"🎲 Seed Value: {seed}")
165
+ print(f"πŸ”„ Variations: {num_vars}")
166
+ print(f"πŸ“ Raw Prompt Mode: {raw_prompt}")
167
+ print(f"πŸ’¬ Text Overlay: {add_text}")
168
+ if add_text:
169
+ print(f"πŸ“ Top Text: '{top_text}'")
170
+ print(f"πŸ“ Bottom Text: '{bottom_text}'")
171
+ print(f"πŸ”€ Font Size: {font_size}")
172
+ print(f"πŸ“ Font Path: {font_path}")
173
+ print("=" * 80)
174
+ print("πŸš€ Starting image generation...")
175
+ print("=" * 80)
176
+ return datetime.now() # Return start time for timing calculation
177
+
178
+
179
+ def debug_generation_complete(start_time, num_vars):
180
+ """
181
+ Debug function to print generation completion time and performance metrics.
182
+
183
+ Args:
184
+ start_time: The datetime when generation started
185
+ num_vars: Number of variations generated
186
+ """
187
+ end_time = datetime.now()
188
+ total_time = end_time - start_time
189
+ total_seconds = total_time.total_seconds()
190
+
191
+ print("=" * 80)
192
+ print("βœ… MEME GENERATION COMPLETED")
193
+ print("=" * 80)
194
+ print(f"⏱️ Total Time: {total_seconds:.2f} seconds")
195
+ print(f"πŸ–ΌοΈ Images Generated: {num_vars}")
196
+ if num_vars > 1:
197
+ print(f"⏱️ Average Time per Image: {total_seconds/num_vars:.2f} seconds")
198
+ print(f"🏁 Finished at: {end_time.strftime('%Y-%m-%d %H:%M:%S')}")
199
+ print("=" * 80)
200
+
201
+
202
  def get_example_prompts():
203
  """
204
  Return a list of example prompts for inspiration.
 
367
 
368
  # Generate
369
  if generate and prompt:
370
+ # Debug: Print all generation inputs and get start time
371
+ start_time = debug_generation_inputs(
372
+ timestamp=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
373
+ prompt=prompt,
374
+ style=style,
375
+ steps=steps,
376
+ guidance=guidance,
377
+ seed=seed,
378
+ model=selected_model,
379
+ top_text=top_text,
380
+ bottom_text=bottom_text,
381
+ num_vars=num_vars,
382
+ raw_prompt=use_raw_prompt,
383
+ use_seed=use_seed,
384
+ add_text=add_text,
385
+ font_size=font_size,
386
+ font_path=font_path
387
+ )
388
+
389
  try:
390
  generator = load_generator(selected_model)
391
  processor = ImageProcessor()
 
436
  step_progress.empty()
437
  step_status.empty()
438
 
439
+ # Debug: Print completion time and performance metrics
440
+ debug_generation_complete(start_time, num_vars)
441
+
442
  # Show result
443
  if num_vars == 1:
444
  placeholder.image(image, use_column_width=True)