goumsss Claude Sonnet 4.6 commited on
Commit
940cec7
·
1 Parent(s): 421007a

Widen layout, more title padding, verbose image gen logging

Browse files

- max-width 420px → 680px so footer fits on one line
- step title (h3) padding increased
- generate_image() now logs animals/places/prompt/result/errors with traceback
- image_generator._generate() returns error string instead of "" on failure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (2) hide show
  1. app.py +12 -4
  2. image_generator.py +4 -2
app.py CHANGED
@@ -171,16 +171,22 @@ def generate_image(state: dict):
171
  places = state.get("selected_places", [random.choice(PLACE_EMOJIS)])
172
  streak = state.get("streak", 0)
173
 
174
- result, _ = generate_reward_image(streak, animals, places)
 
 
175
 
176
  if result is None:
 
177
  return (gr.update(visible=False), None,
178
  "⚠️ Could not generate image — try again later!")
179
 
 
180
  return gr.update(visible=False), result, ""
181
 
182
  except Exception as e:
183
- print(f"generate_image error: {e}")
 
 
184
  return gr.update(visible=False), None, f"⚠️ Error: {e}"
185
 
186
  # ---------------------------------------------------------------------------
@@ -196,8 +202,10 @@ def restart(state: dict):
196
  # ---------------------------------------------------------------------------
197
 
198
  CSS = """
199
- .gradio-container { max-width: 420px !important; margin: 0 auto !important; }
200
- .gradio-group > .form { padding: 12px 16px !important; }
 
 
201
  #title { text-align: center; font-size: 2.2em; margin-bottom: 0.1em; }
202
  #subtitle { text-align: center; color: #888; margin-bottom: 1em; font-style: italic; }
203
  #question-box { text-align: center; font-size: 2.6em; font-weight: bold; padding: 0.5em; }
 
171
  places = state.get("selected_places", [random.choice(PLACE_EMOJIS)])
172
  streak = state.get("streak", 0)
173
 
174
+ print(f"[generate_image] calling generate_reward_image | streak={streak} | animals={animals} | places={places}")
175
+ result, prompt = generate_reward_image(streak, animals, places)
176
+ print(f"[generate_image] result={result} | prompt={prompt!r}")
177
 
178
  if result is None:
179
+ print("[generate_image] ⚠️ result is None — generation failed silently inside image_generator")
180
  return (gr.update(visible=False), None,
181
  "⚠️ Could not generate image — try again later!")
182
 
183
+ print("[generate_image] ✅ image generated successfully")
184
  return gr.update(visible=False), result, ""
185
 
186
  except Exception as e:
187
+ import traceback
188
+ print(f"[generate_image] ❌ exception: {e}")
189
+ print(traceback.format_exc())
190
  return gr.update(visible=False), None, f"⚠️ Error: {e}"
191
 
192
  # ---------------------------------------------------------------------------
 
202
  # ---------------------------------------------------------------------------
203
 
204
  CSS = """
205
+ .gradio-container { max-width: 680px !important; margin: 0 auto !important; }
206
+ .gradio-group > .form { padding: 16px 20px !important; }
207
+ .gradio-group > .form > .gap > .prose h3,
208
+ .gradio-group > .form > .gap > p { padding-top: 8px !important; padding-bottom: 4px !important; }
209
  #title { text-align: center; font-size: 2.2em; margin-bottom: 0.1em; }
210
  #subtitle { text-align: center; color: #888; margin-bottom: 1em; font-style: italic; }
211
  #question-box { text-align: center; font-size: 2.6em; font-weight: bold; padding: 0.5em; }
image_generator.py CHANGED
@@ -134,8 +134,10 @@ def _generate(streak: int, animals: list[str], places: list[str]):
134
  return result.images[0], prompt
135
 
136
  except Exception as e:
137
- print(f"Image generation failed: {e}")
138
- return None, ""
 
 
139
 
140
 
141
  # ---------------------------------------------------------------------------
 
134
  return result.images[0], prompt
135
 
136
  except Exception as e:
137
+ import traceback
138
+ print(f"[image_generator] generation failed: {e}")
139
+ print(traceback.format_exc())
140
+ return None, str(e)
141
 
142
 
143
  # ---------------------------------------------------------------------------