Ephemeral182 commited on
Commit
7e009fb
Β·
verified Β·
1 Parent(s): f0ad3b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -64
app.py CHANGED
@@ -209,6 +209,7 @@ def create_interface():
209
 
210
  custom_css = """
211
  .gradio-container {
 
212
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
213
  }
214
 
@@ -216,8 +217,7 @@ def create_interface():
216
  background: rgba(255, 255, 255, 0.95);
217
  border-radius: 15px;
218
  padding: 25px;
219
- margin: 15px auto;
220
- max-width: 1200px;
221
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
222
  }
223
 
@@ -238,6 +238,17 @@ def create_interface():
238
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
239
  }
240
 
 
 
 
 
 
 
 
 
 
 
 
241
  .section-header {
242
  background: linear-gradient(135deg, #a8edea, #fed6e3);
243
  padding: 12px;
@@ -288,73 +299,28 @@ button.primary {
288
  font-weight: bold !important;
289
  font-size: 15px !important;
290
  box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4) !important;
291
- transition: all 0.2s ease-in-out;
292
  }
293
 
294
  button.primary:hover {
295
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6) !important;
296
- transform: translateY(-2px);
297
- opacity: 0.95 !important;
298
  }
299
 
300
- .examples .gallery {
301
- gap: 8px !important;
302
- }
303
-
304
- .examples .gallery-item {
305
- border-radius: 8px !important;
306
- background-color: #f0f0f0 !important;
307
- border: 1px solid #ddd !important;
308
- padding: 10px !important;
309
  text-align: left !important;
310
- transition: background-color 0.2s, border-color 0.2s;
311
- }
312
-
313
- .examples .gallery-item:hover {
314
- background-color: #e0e0e0 !important;
315
- border-color: #ccc !important;
316
- }
317
-
318
- .examples .gallery-item span {
319
- font-size: 14px !important;
320
- white-space: normal !important;
321
- width: 100% !important;
322
- }
323
-
324
- .image-output-container {
325
- display: flex;
326
- justify-content: center;
327
- align-items: center;
328
- min-height: 512px;
329
- background: #f0f2f5;
330
- border-radius: 12px;
331
- overflow: hidden;
332
- }
333
-
334
- .image-output-container img {
335
- max-height: 512px;
336
- max-width: 100%;
337
- object-fit: contain;
338
- }
339
-
340
- .preserve-aspect-ratio img {
341
- object-fit: contain !important;
342
- width: auto !important;
343
- max-height: 512px !important;
344
  }
345
  """
346
 
347
  with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
348
  with gr.Column(elem_classes="contain"):
349
  gr.HTML('<div class="title-container"><h1>🎨 PosterCraft-v1.0</h1></div>')
350
-
351
- with gr.Row(equal_height=False):
352
  with gr.Column(scale=1, elem_classes="input-group"):
353
  gr.HTML('<div class="section-header"><h3>βš™οΈ 1. Configuration</h3></div>')
354
  prompt_input = gr.Textbox(label="πŸ’‘ Prompt", lines=3, placeholder="Enter your creative prompt...")
355
-
356
- enable_recap_checkbox = gr.Checkbox(label="πŸ”„ Enable Prompt Recap", value=True, info=f"Uses {DEFAULT_QWEN_MODEL_PATH} for rewriting.")
357
-
358
  gr.Examples(
359
  examples=[
360
  ["Urban Canvas Street Art Expo poster with bold graffiti-style lettering and dynamic colorful splashes"],
@@ -364,7 +330,7 @@ button.primary:hover {
364
  ],
365
  inputs=[prompt_input],
366
  label="πŸ“ Example Prompts",
367
- examples_per_page=5,
368
  )
369
 
370
  with gr.Row():
@@ -374,24 +340,23 @@ button.primary:hover {
374
 
375
  num_inference_steps_input = gr.Slider(label="πŸ”„ Inference Steps", minimum=1, maximum=100, value=28, step=1)
376
  guidance_scale_input = gr.Slider(label="🎯 Guidance Scale (CFG)", minimum=0.0, maximum=20.0, value=3.5, step=0.1)
377
- seed_number_input = gr.Number(label="🎲 Seed", value=-1, minimum=-1, step=1, info="Leave blank or set to -1 for a random seed.")
378
  generate_button = gr.Button("πŸš€ Generate Image", variant="primary")
379
 
380
  with gr.Column(scale=1, elem_classes="result-section"):
381
  gr.HTML('<div class="section-header"><h3>🎨 2. Results</h3></div>')
382
- with gr.Group(elem_classes=["image-output-container"]):
383
- image_output = gr.Image(label="πŸ–ΌοΈ Generated Image", type="pil", show_download_button=True, height=512, elem_classes=["preserve-aspect-ratio"])
384
  recapped_prompt_output = gr.Textbox(label="πŸ“ Final Prompt Used", lines=5, interactive=False)
385
  status_output = gr.Textbox(label="πŸ“Š Status Log", lines=4, interactive=False)
386
 
387
- inputs_list = [
388
- prompt_input, enable_recap_checkbox, height_input, width_input,
389
- num_inference_steps_input, guidance_scale_input, seed_number_input
390
- ]
391
- outputs_list = [image_output, status_output, recapped_prompt_output]
 
 
392
 
393
- generate_button.click(fn=generate_poster, inputs=inputs_list, outputs=outputs_list)
394
-
395
  return demo
396
 
397
  if __name__ == "__main__":
 
209
 
210
  custom_css = """
211
  .gradio-container {
212
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
213
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
214
  }
215
 
 
217
  background: rgba(255, 255, 255, 0.95);
218
  border-radius: 15px;
219
  padding: 25px;
220
+ margin: 15px;
 
221
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
222
  }
223
 
 
238
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
239
  }
240
 
241
+ .info-bar {
242
+ background: linear-gradient(135deg, #4facfe, #00f2fe);
243
+ padding: 12px;
244
+ border-radius: 8px;
245
+ margin-bottom: 20px;
246
+ color: white;
247
+ text-align: center;
248
+ font-weight: 500;
249
+ box-shadow: 0 3px 12px rgba(79, 172, 254, 0.3);
250
+ }
251
+
252
  .section-header {
253
  background: linear-gradient(135deg, #a8edea, #fed6e3);
254
  padding: 12px;
 
299
  font-weight: bold !important;
300
  font-size: 15px !important;
301
  box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4) !important;
 
302
  }
303
 
304
  button.primary:hover {
305
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6) !important;
306
+ opacity: 0.9 !important;
 
307
  }
308
 
309
+ .examples .example-button {
 
 
 
 
 
 
 
 
310
  text-align: left !important;
311
+ justify-content: flex-start !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  }
313
  """
314
 
315
  with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
316
  with gr.Column(elem_classes="contain"):
317
  gr.HTML('<div class="title-container"><h1>🎨 PosterCraft-v1.0</h1></div>')
318
+
319
+ with gr.Row():
320
  with gr.Column(scale=1, elem_classes="input-group"):
321
  gr.HTML('<div class="section-header"><h3>βš™οΈ 1. Configuration</h3></div>')
322
  prompt_input = gr.Textbox(label="πŸ’‘ Prompt", lines=3, placeholder="Enter your creative prompt...")
323
+ enable_recap_checkbox = gr.Checkbox(label="πŸ”„ Enable Prompt Recap", value=True, info=f"Uses Qwen3 for rewriting.")
 
 
324
  gr.Examples(
325
  examples=[
326
  ["Urban Canvas Street Art Expo poster with bold graffiti-style lettering and dynamic colorful splashes"],
 
330
  ],
331
  inputs=[prompt_input],
332
  label="πŸ“ Example Prompts",
333
+ examples_per_page=5
334
  )
335
 
336
  with gr.Row():
 
340
 
341
  num_inference_steps_input = gr.Slider(label="πŸ”„ Inference Steps", minimum=1, maximum=100, value=28, step=1)
342
  guidance_scale_input = gr.Slider(label="🎯 Guidance Scale (CFG)", minimum=0.0, maximum=20.0, value=3.5, step=0.1)
343
+ seed_number_input = gr.Number(label="🎲 Seed", value=None, minimum=-1, step=1, info="Leave blank or set to -1 for a random seed.")
344
  generate_button = gr.Button("πŸš€ Generate Image", variant="primary")
345
 
346
  with gr.Column(scale=1, elem_classes="result-section"):
347
  gr.HTML('<div class="section-header"><h3>🎨 2. Results</h3></div>')
348
+ image_output = gr.Image(label="πŸ–ΌοΈ Generated Image", type="pil", show_download_button=True, height=512)
 
349
  recapped_prompt_output = gr.Textbox(label="πŸ“ Final Prompt Used", lines=5, interactive=False)
350
  status_output = gr.Textbox(label="πŸ“Š Status Log", lines=4, interactive=False)
351
 
352
+ inputs_list = [
353
+ prompt_input, enable_recap_checkbox, height_input, width_input,
354
+ num_inference_steps_input, guidance_scale_input, seed_number_input
355
+ ]
356
+ outputs_list = [image_output, recapped_prompt_output, status_output]
357
+
358
+ generate_button.click(fn=generate_poster, inputs=inputs_list, outputs=outputs_list)
359
 
 
 
360
  return demo
361
 
362
  if __name__ == "__main__":