someone-in-the-world Claude Sonnet 4.6 commited on
Commit
62ddcce
·
1 Parent(s): f538c34

Load Quick Prompts from suggestions.json, replace artistic chips with realistic ones

Browse files
Files changed (3) hide show
  1. app.py +17 -1
  2. suggestions.json +34 -0
  3. templates/app.html +1 -16
app.py CHANGED
@@ -71,6 +71,9 @@ print("torch.compile skipped: lazy Triton kernel compilation inside @spaces.GPU
71
  with open("examples.json") as _f:
72
  EXAMPLES_CONFIG = json.load(_f)
73
 
 
 
 
74
 
75
  def make_thumb_b64(path, max_dim=220):
76
  if not os.path.exists(path):
@@ -150,9 +153,19 @@ def load_example_data(idx_str):
150
  return json.dumps({"images": b64_list, "prompt": ex["prompt"], "names": names, "status": "ok"})
151
 
152
 
 
 
 
 
 
 
 
 
153
  print("Building example thumbnails...")
154
  EXAMPLE_CARDS_HTML = build_example_cards_html()
155
  print(f"Built {len(EXAMPLES_CONFIG)} example cards.")
 
 
156
 
157
 
158
  def b64_to_pil_list(b64_json_str):
@@ -293,7 +306,10 @@ with open("static/negative_prompt.txt") as _f:
293
  # ── HTML template ──────────────────────────────────────────────────────────────
294
 
295
  with open("templates/app.html") as _f:
296
- app_html = _f.read().format(example_cards_html=EXAMPLE_CARDS_HTML)
 
 
 
297
 
298
  # ── Gradio blocks ──────────────────────────────────────────────────────────────
299
 
 
71
  with open("examples.json") as _f:
72
  EXAMPLES_CONFIG = json.load(_f)
73
 
74
+ with open("suggestions.json") as _f:
75
+ SUGGESTIONS_CONFIG = json.load(_f)
76
+
77
 
78
  def make_thumb_b64(path, max_dim=220):
79
  if not os.path.exists(path):
 
153
  return json.dumps({"images": b64_list, "prompt": ex["prompt"], "names": names, "status": "ok"})
154
 
155
 
156
+ def build_suggestion_chips_html():
157
+ return "".join(
158
+ f'<button class="suggestion-chip" onclick="window.__setPrompt({json.dumps(s[\'prompt\'])})">'
159
+ f'{html_lib.escape(s["label"])}</button>'
160
+ for s in SUGGESTIONS_CONFIG
161
+ )
162
+
163
+
164
  print("Building example thumbnails...")
165
  EXAMPLE_CARDS_HTML = build_example_cards_html()
166
  print(f"Built {len(EXAMPLES_CONFIG)} example cards.")
167
+ SUGGESTION_CHIPS_HTML = build_suggestion_chips_html()
168
+ print(f"Built {len(SUGGESTIONS_CONFIG)} suggestion chips.")
169
 
170
 
171
  def b64_to_pil_list(b64_json_str):
 
306
  # ── HTML template ──────────────────────────────────────────────────────────────
307
 
308
  with open("templates/app.html") as _f:
309
+ app_html = _f.read().format(
310
+ example_cards_html=EXAMPLE_CARDS_HTML,
311
+ suggestion_chips_html=SUGGESTION_CHIPS_HTML,
312
+ )
313
 
314
  # ── Gradio blocks ──────────────────────────────────────────────────────────────
315
 
suggestions.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "label": "Enhance Detail",
4
+ "prompt": "Enhance and upscale the image with sharper detail, improved texture clarity, and natural color depth. Preserve the original composition and lighting."
5
+ },
6
+ {
7
+ "label": "Portrait Retouch",
8
+ "prompt": "Apply professional portrait retouching: smooth skin naturally, even out tones, brighten eyes, and reduce blemishes while keeping the result realistic and lifelike."
9
+ },
10
+ {
11
+ "label": "Restore & Clarify",
12
+ "prompt": "Restore and upscale the image with improved clarity, recovered shadow detail, and reduced compression artifacts. Keep all original content intact."
13
+ },
14
+ {
15
+ "label": "Denoise & Clean",
16
+ "prompt": "Remove noise and grain, recover fine texture in skin and fabric, and produce a clean, sharp result as if shot in a professional studio."
17
+ },
18
+ {
19
+ "label": "Studio Backdrop",
20
+ "prompt": "Replace the background with a seamless, softly blurred light grey studio backdrop. Keep the subject sharp and perfectly separated from the background."
21
+ },
22
+ {
23
+ "label": "Night Street",
24
+ "prompt": "Change the setting to a wet urban street at night with warm streetlights, neon reflections on the ground, and a shallow depth of field. Keep the subject unchanged."
25
+ },
26
+ {
27
+ "label": "Bokeh Blur",
28
+ "prompt": "Add a smooth, circular bokeh blur to the background while keeping the subject in sharp focus. Use natural out-of-focus highlights consistent with a wide-aperture lens."
29
+ },
30
+ {
31
+ "label": "Autumn Scene",
32
+ "prompt": "Change the surroundings to an autumn scene with warm golden and red foliage, soft natural light filtering through the trees, and a slight atmospheric haze."
33
+ }
34
+ ]
templates/app.html CHANGED
@@ -60,22 +60,7 @@
60
  <div class="suggestions-section">
61
  <div class="suggestions-title">Quick Prompts</div>
62
  <div class="suggestions-wrap">
63
- <button class="suggestion-chip" onclick="window.__setPrompt('Transform the image into a dotted cartoon style.')">Cartoon Style</button>
64
- <button class="suggestion-chip" onclick="window.__setPrompt('Convert it to black and white.')">Black and White</button>
65
- <button class="suggestion-chip" onclick="window.__setPrompt('Add cinematic lighting with warm orange tones and film grain.')">Cinematic</button>
66
- <button class="suggestion-chip" onclick="window.__setPrompt('Transform into anime style illustration.')">Anime Style</button>
67
- <button class="suggestion-chip" onclick="window.__setPrompt('Apply oil painting effect with visible brush strokes.')">Oil Painting</button>
68
- <button class="suggestion-chip" onclick="window.__setPrompt('Enhance and upscale with more detail and clarity.')">Enhance</button>
69
- <button class="suggestion-chip" onclick="window.__setPrompt('Make it look like a watercolor painting with soft edges.')">Watercolor</button>
70
- <button class="suggestion-chip" onclick="window.__setPrompt('Add dramatic sunset sky and warm lighting.')">Sunset Glow</button>
71
- <button class="suggestion-chip" onclick="window.__setPrompt('Convert to detailed pencil sketch with cross-hatching and shading.')">Pencil Sketch</button>
72
- <button class="suggestion-chip" onclick="window.__setPrompt('Apply pop art style with bold colors and halftone patterns.')">Pop Art</button>
73
- <button class="suggestion-chip" onclick="window.__setPrompt('Apply a vintage retro film look with faded colors and light leaks.')">Vintage Retro</button>
74
- <button class="suggestion-chip" onclick="window.__setPrompt('Add neon glow effects with vibrant colors against a dark background.')">Neon Glow</button>
75
- <button class="suggestion-chip" onclick="window.__setPrompt('Convert to pixel art style with a retro 16-bit aesthetic.')">Pixel Art</button>
76
- <button class="suggestion-chip" onclick="window.__setPrompt('Simplify into a clean minimalist illustration with flat colors.')">Minimalist</button>
77
- <button class="suggestion-chip" onclick="window.__setPrompt('Convert to low poly 3D geometric art style.')">Low Poly 3D</button>
78
- <button class="suggestion-chip" onclick="window.__setPrompt('Transform into comic book style with bold outlines and cel shading.')">Comic Book</button>
79
  </div>
80
  </div>
81
 
 
60
  <div class="suggestions-section">
61
  <div class="suggestions-title">Quick Prompts</div>
62
  <div class="suggestions-wrap">
63
+ {suggestion_chips_html}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  </div>
65
  </div>
66