fantos commited on
Commit
67818cd
·
verified ·
1 Parent(s): 7f00770

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +183 -113
app.py CHANGED
@@ -87,234 +87,304 @@ def update_dimensions_from_image(image_list):
87
  return new_width, new_height
88
 
89
  css = """
90
- /* Glassmorphism Style */
 
 
 
 
 
 
91
  body, .gradio-container {
92
- background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%) !important;
93
  min-height: 100vh;
94
  }
95
 
 
 
 
 
 
 
 
 
96
  #col-container {
97
  margin: 0 auto;
98
- max-width: 1100px;
99
- padding: 30px 20px;
100
  }
101
 
102
- /* Header Section */
103
- .header-section {
 
 
 
 
104
  text-align: center;
105
- margin-bottom: 30px;
 
 
 
106
  }
107
 
108
- .badge-container {
109
  display: flex;
110
  justify-content: center;
111
- margin-bottom: 15px;
112
  }
113
 
114
  .title-text {
115
- font-size: 2.5rem !important;
116
- font-weight: 700 !important;
117
- background: linear-gradient(135deg, #667eea, #764ba2, #f093fb) !important;
118
- -webkit-background-clip: text !important;
119
- -webkit-text-fill-color: transparent !important;
120
- background-clip: text !important;
121
- margin: 10px 0 5px 0 !important;
122
  }
123
 
124
  .subtitle-text {
125
- color: rgba(255, 255, 255, 0.7) !important;
126
- font-size: 1rem !important;
 
127
  margin: 0 !important;
128
  }
129
 
130
- /* Glass Cards */
131
- .glass-card {
132
- background: rgba(255, 255, 255, 0.08) !important;
133
- backdrop-filter: blur(20px) !important;
134
- -webkit-backdrop-filter: blur(20px) !important;
135
- border: 1px solid rgba(255, 255, 255, 0.15) !important;
136
- border-radius: 20px !important;
137
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
138
  padding: 20px !important;
 
 
 
139
  }
140
 
141
  .gr-panel, .gr-box, .gr-form, .block, .form {
142
- background: rgba(255, 255, 255, 0.05) !important;
143
- backdrop-filter: blur(15px) !important;
144
- border: 1px solid rgba(255, 255, 255, 0.1) !important;
145
- border-radius: 16px !important;
146
  }
147
 
148
  /* Prompt Input */
149
- .prompt-container textarea {
150
- background: rgba(255, 255, 255, 0.08) !important;
151
- border: 2px solid rgba(255, 255, 255, 0.15) !important;
152
- border-radius: 14px !important;
153
- color: white !important;
154
- font-size: 1rem !important;
155
- padding: 15px !important;
156
- min-height: 80px !important;
 
157
  transition: all 0.3s ease !important;
158
  }
159
 
160
- .prompt-container textarea:focus {
161
- border-color: rgba(102, 126, 234, 0.6) !important;
162
- box-shadow: 0 0 20px rgba(102, 126, 234, 0.3) !important;
163
  }
164
 
165
- .prompt-container textarea::placeholder {
166
- color: rgba(255, 255, 255, 0.4) !important;
 
167
  }
168
 
169
  /* Generate Button */
170
- .generate-btn {
171
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
172
- border: none !important;
173
- border-radius: 14px !important;
174
- color: white !important;
175
- font-weight: 600 !important;
176
- font-size: 1.1rem !important;
177
- padding: 14px 30px !important;
178
  transition: all 0.3s ease !important;
179
- box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4) !important;
 
 
 
180
  }
181
 
182
- .generate-btn:hover {
183
- transform: translateY(-3px) !important;
184
- box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6) !important;
 
 
 
 
 
 
185
  }
186
 
187
  /* Result Image */
188
- .result-container {
189
- background: rgba(255, 255, 255, 0.05) !important;
190
- border-radius: 20px !important;
191
- border: 1px solid rgba(255, 255, 255, 0.1) !important;
192
- overflow: hidden !important;
193
- min-height: 400px !important;
 
 
 
194
  }
195
 
196
- .result-container img {
197
- border-radius: 16px !important;
198
  }
199
 
200
  /* Accordion */
201
  .gr-accordion {
202
- background: rgba(255, 255, 255, 0.05) !important;
203
- border: 1px solid rgba(255, 255, 255, 0.1) !important;
204
- border-radius: 14px !important;
205
  margin-top: 15px !important;
 
206
  }
207
 
208
  .gr-accordion-header {
209
- color: rgba(255, 255, 255, 0.9) !important;
210
- font-weight: 500 !important;
 
 
211
  }
212
 
213
  /* Gallery */
214
- .gallery-container {
215
- background: rgba(255, 255, 255, 0.03) !important;
 
 
 
 
 
 
216
  border-radius: 12px !important;
217
- padding: 10px !important;
218
  }
219
 
220
- .gallery-container img {
221
- object-fit: contain;
222
- border-radius: 10px !important;
 
223
  }
224
 
225
- /* Sliders & Inputs */
226
  input[type="range"] {
227
- accent-color: #667eea !important;
228
  }
229
 
230
- label, .label-wrap, span {
231
- color: rgba(255, 255, 255, 0.85) !important;
 
232
  }
233
 
 
234
  input[type="number"] {
235
- background: rgba(255, 255, 255, 0.08) !important;
236
- border: 1px solid rgba(255, 255, 255, 0.15) !important;
237
- border-radius: 8px !important;
238
- color: white !important;
 
239
  }
240
 
241
  /* Checkbox */
242
  input[type="checkbox"] {
243
- accent-color: #667eea !important;
 
 
244
  }
245
 
246
  /* Scrollbar */
247
  ::-webkit-scrollbar {
248
- width: 6px;
249
  }
250
 
251
  ::-webkit-scrollbar-track {
252
- background: rgba(255, 255, 255, 0.05);
253
- border-radius: 3px;
254
  }
255
 
256
  ::-webkit-scrollbar-thumb {
257
- background: rgba(255, 255, 255, 0.2);
258
- border-radius: 3px;
259
  }
260
 
261
- /* Row Balance */
262
  .main-row {
263
  gap: 25px !important;
 
264
  }
265
 
266
- .input-column {
267
  flex: 1 !important;
268
  }
269
 
270
- .output-column {
271
- flex: 1.2 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  }
273
  """
274
 
275
  with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
276
 
277
  with gr.Column(elem_id="col-container"):
278
- # Header with centered badge
279
  gr.HTML("""
280
- <div class="header-section">
281
- <div class="badge-container">
282
  <a href="https://www.humangen.ai" target="_blank">
283
- <img src="https://img.shields.io/static/v1?label=Free%20AI%20HUB&message=humangen.ai&color=%230000ff&labelColor=%23800080&logo=huggingface&logoColor=white&style=for-the-badge" alt="badge">
284
  </a>
285
  </div>
286
- <h1 class="title-text">✨ GLM-Image Generator</h1>
287
- <p class="subtitle-text">9B hybrid AI model for text-accurate image generation</p>
288
  </div>
289
  """)
290
 
291
  with gr.Row(elem_classes="main-row"):
292
- # Left Column - Input
293
- with gr.Column(elem_classes="input-column"):
294
- with gr.Group(elem_classes="glass-card"):
295
  prompt = gr.Text(
296
  label="Prompt",
297
  show_label=False,
298
  max_lines=4,
299
- placeholder="✍️ Describe the image you want to create...",
300
  container=False,
301
- elem_classes="prompt-container"
302
  )
303
 
304
- run_button = gr.Button("🎨 Generate Image", variant="primary", elem_classes="generate-btn")
305
 
306
- with gr.Accordion("📷 Input Images (Optional)", open=False):
307
  input_images = gr.Gallery(
308
- label="Upload for image-to-image mode",
309
  type="pil",
310
  columns=3,
311
  rows=1,
312
- elem_classes="gallery-container"
313
  )
314
 
315
- with gr.Accordion("⚙️ Advanced Settings", open=False):
316
- seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42)
317
- randomize_seed = gr.Checkbox(label="🎲 Randomize seed", value=True)
318
 
319
  with gr.Row():
320
  width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
@@ -324,9 +394,9 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
324
  num_inference_steps = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=50)
325
  guidance_scale = gr.Slider(label="Guidance", minimum=0.0, maximum=10.0, step=0.1, value=1.5)
326
 
327
- # Right Column - Output
328
- with gr.Column(elem_classes="output-column"):
329
- result = gr.Image(label="Generated Image", show_label=False, elem_classes="result-container")
330
 
331
  input_images.upload(
332
  fn=update_dimensions_from_image,
 
87
  return new_width, new_height
88
 
89
  css = """
90
+ /* Candy Pastel Style */
91
+ @import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');
92
+
93
+ * {
94
+ font-family: 'Nunito', sans-serif !important;
95
+ }
96
+
97
  body, .gradio-container {
98
+ background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 50%, #ffecd2 100%) !important;
99
  min-height: 100vh;
100
  }
101
 
102
+ .gradio-container {
103
+ background:
104
+ radial-gradient(circle at 20% 80%, rgba(255, 182, 193, 0.4) 0%, transparent 50%),
105
+ radial-gradient(circle at 80% 20%, rgba(173, 216, 230, 0.4) 0%, transparent 50%),
106
+ radial-gradient(circle at 40% 40%, rgba(221, 160, 221, 0.3) 0%, transparent 40%),
107
+ linear-gradient(135deg, #fff5f5 0%, #fef3e2 50%, #f0fff4 100%) !important;
108
+ }
109
+
110
  #col-container {
111
  margin: 0 auto;
112
+ max-width: 1150px;
113
+ padding: 25px 20px;
114
  }
115
 
116
+ /* Header */
117
+ .header-box {
118
+ background: linear-gradient(135deg, #ffffff 0%, #fff5f8 100%);
119
+ border: 3px solid #ffb6c1;
120
+ border-radius: 30px;
121
+ padding: 25px;
122
  text-align: center;
123
+ margin-bottom: 25px;
124
+ box-shadow:
125
+ 0 10px 30px rgba(255, 182, 193, 0.3),
126
+ inset 0 -3px 0 rgba(255, 182, 193, 0.2);
127
  }
128
 
129
+ .badge-row {
130
  display: flex;
131
  justify-content: center;
132
+ margin-bottom: 12px;
133
  }
134
 
135
  .title-text {
136
+ font-size: 2.4rem !important;
137
+ font-weight: 800 !important;
138
+ color: #e75480 !important;
139
+ margin: 8px 0 !important;
140
+ text-shadow: 2px 2px 0 #ffd1dc;
 
 
141
  }
142
 
143
  .subtitle-text {
144
+ color: #b784a7 !important;
145
+ font-size: 1.05rem !important;
146
+ font-weight: 600 !important;
147
  margin: 0 !important;
148
  }
149
 
150
+ /* Cards */
151
+ .pastel-card {
152
+ background: linear-gradient(145deg, #ffffff, #fff8fa) !important;
153
+ border: 3px solid #ffc1cc !important;
154
+ border-radius: 24px !important;
 
 
 
155
  padding: 20px !important;
156
+ box-shadow:
157
+ 0 8px 25px rgba(255, 182, 193, 0.25),
158
+ inset 0 -2px 0 rgba(255, 182, 193, 0.15) !important;
159
  }
160
 
161
  .gr-panel, .gr-box, .gr-form, .block, .form {
162
+ background: #ffffff !important;
163
+ border: 2px solid #e8d5de !important;
164
+ border-radius: 20px !important;
165
+ box-shadow: 0 4px 15px rgba(255, 182, 193, 0.15) !important;
166
  }
167
 
168
  /* Prompt Input */
169
+ .prompt-box textarea {
170
+ background: linear-gradient(135deg, #fff9fb, #ffffff) !important;
171
+ border: 3px solid #ffb6c1 !important;
172
+ border-radius: 18px !important;
173
+ color: #6b4c5a !important;
174
+ font-size: 1.05rem !important;
175
+ font-weight: 600 !important;
176
+ padding: 18px !important;
177
+ min-height: 90px !important;
178
  transition: all 0.3s ease !important;
179
  }
180
 
181
+ .prompt-box textarea:focus {
182
+ border-color: #ff91a4 !important;
183
+ box-shadow: 0 0 0 4px rgba(255, 145, 164, 0.2) !important;
184
  }
185
 
186
+ .prompt-box textarea::placeholder {
187
+ color: #d4a5b5 !important;
188
+ font-weight: 500 !important;
189
  }
190
 
191
  /* Generate Button */
192
+ .candy-btn {
193
+ background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%) !important;
194
+ border: 3px solid #ff8a9e !important;
195
+ border-radius: 50px !important;
196
+ color: #a0405a !important;
197
+ font-weight: 800 !important;
198
+ font-size: 1.15rem !important;
199
+ padding: 16px 35px !important;
200
  transition: all 0.3s ease !important;
201
+ box-shadow:
202
+ 0 6px 20px rgba(255, 154, 158, 0.4),
203
+ inset 0 -3px 0 rgba(255, 120, 140, 0.3) !important;
204
+ text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
205
  }
206
 
207
+ .candy-btn:hover {
208
+ transform: translateY(-3px) scale(1.02) !important;
209
+ box-shadow:
210
+ 0 10px 30px rgba(255, 154, 158, 0.5),
211
+ inset 0 -3px 0 rgba(255, 120, 140, 0.3) !important;
212
+ }
213
+
214
+ .candy-btn:active {
215
+ transform: translateY(0) scale(0.98) !important;
216
  }
217
 
218
  /* Result Image */
219
+ .result-box {
220
+ background: linear-gradient(145deg, #ffffff, #fff5f8) !important;
221
+ border: 3px solid #b5e8e3 !important;
222
+ border-radius: 24px !important;
223
+ padding: 15px !important;
224
+ box-shadow:
225
+ 0 8px 25px rgba(181, 232, 227, 0.3),
226
+ inset 0 -2px 0 rgba(181, 232, 227, 0.2) !important;
227
+ min-height: 450px !important;
228
  }
229
 
230
+ .result-box img {
231
+ border-radius: 18px !important;
232
  }
233
 
234
  /* Accordion */
235
  .gr-accordion {
236
+ background: linear-gradient(145deg, #fff8fa, #ffffff) !important;
237
+ border: 2px solid #dda0dd !important;
238
+ border-radius: 18px !important;
239
  margin-top: 15px !important;
240
+ overflow: hidden !important;
241
  }
242
 
243
  .gr-accordion-header {
244
+ background: linear-gradient(135deg, #f8e1f4, #fce4ec) !important;
245
+ color: #8b668b !important;
246
+ font-weight: 700 !important;
247
+ padding: 12px 18px !important;
248
  }
249
 
250
  /* Gallery */
251
+ .gallery-box {
252
+ background: #fffbfc !important;
253
+ border-radius: 16px !important;
254
+ padding: 12px !important;
255
+ border: 2px dashed #f0b6c4 !important;
256
+ }
257
+
258
+ .gallery-box img {
259
  border-radius: 12px !important;
260
+ border: 2px solid #ffd1dc !important;
261
  }
262
 
263
+ /* Labels */
264
+ label, .label-wrap, span {
265
+ color: #7a5a6a !important;
266
+ font-weight: 600 !important;
267
  }
268
 
269
+ /* Sliders */
270
  input[type="range"] {
271
+ accent-color: #ff91a4 !important;
272
  }
273
 
274
+ input[type="range"]::-webkit-slider-track {
275
+ background: linear-gradient(90deg, #ffd1dc, #b5e8e3) !important;
276
+ border-radius: 10px !important;
277
  }
278
 
279
+ /* Number Input */
280
  input[type="number"] {
281
+ background: #fff9fb !important;
282
+ border: 2px solid #e8d5de !important;
283
+ border-radius: 12px !important;
284
+ color: #6b4c5a !important;
285
+ font-weight: 600 !important;
286
  }
287
 
288
  /* Checkbox */
289
  input[type="checkbox"] {
290
+ accent-color: #ff91a4 !important;
291
+ width: 18px !important;
292
+ height: 18px !important;
293
  }
294
 
295
  /* Scrollbar */
296
  ::-webkit-scrollbar {
297
+ width: 10px;
298
  }
299
 
300
  ::-webkit-scrollbar-track {
301
+ background: #fff0f3;
302
+ border-radius: 5px;
303
  }
304
 
305
  ::-webkit-scrollbar-thumb {
306
+ background: linear-gradient(180deg, #ffb6c1, #dda0dd);
307
+ border-radius: 5px;
308
  }
309
 
310
+ /* Layout Balance */
311
  .main-row {
312
  gap: 25px !important;
313
+ align-items: flex-start !important;
314
  }
315
 
316
+ .input-col {
317
  flex: 1 !important;
318
  }
319
 
320
+ .output-col {
321
+ flex: 1.1 !important;
322
+ }
323
+
324
+ /* Settings Grid */
325
+ .settings-row {
326
+ display: flex;
327
+ gap: 15px;
328
+ }
329
+
330
+ /* Decorative Elements */
331
+ .deco-dots {
332
+ position: absolute;
333
+ width: 100%;
334
+ height: 100%;
335
+ background-image:
336
+ radial-gradient(#ffd1dc 2px, transparent 2px),
337
+ radial-gradient(#b5e8e3 2px, transparent 2px);
338
+ background-size: 30px 30px;
339
+ background-position: 0 0, 15px 15px;
340
+ opacity: 0.3;
341
+ pointer-events: none;
342
  }
343
  """
344
 
345
  with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
346
 
347
  with gr.Column(elem_id="col-container"):
348
+ # Header
349
  gr.HTML("""
350
+ <div class="header-box">
351
+ <div class="badge-row">
352
  <a href="https://www.humangen.ai" target="_blank">
353
+ <img src="https://img.shields.io/static/v1?label=Free%20AI%20HUB&message=humangen.ai&color=%23ff91a4&labelColor=%23b5e8e3&logo=huggingface&logoColor=white&style=for-the-badge" alt="badge">
354
  </a>
355
  </div>
356
+ <h1 class="title-text">🍬 GLM-Image Generator</h1>
357
+ <p class="subtitle-text">✨ 9B hybrid AI model for text-accurate image generation</p>
358
  </div>
359
  """)
360
 
361
  with gr.Row(elem_classes="main-row"):
362
+ # Left - Input
363
+ with gr.Column(elem_classes="input-col"):
364
+ with gr.Group(elem_classes="pastel-card"):
365
  prompt = gr.Text(
366
  label="Prompt",
367
  show_label=False,
368
  max_lines=4,
369
+ placeholder="🎨 Describe the image you want to create...",
370
  container=False,
371
+ elem_classes="prompt-box"
372
  )
373
 
374
+ run_button = gr.Button("🍭 Generate Image", variant="primary", elem_classes="candy-btn")
375
 
376
+ with gr.Accordion("🖼️ Input Images (Optional)", open=False, elem_classes="accordion-box"):
377
  input_images = gr.Gallery(
378
+ label="Upload images",
379
  type="pil",
380
  columns=3,
381
  rows=1,
382
+ elem_classes="gallery-box"
383
  )
384
 
385
+ with gr.Accordion("⚙️ Settings", open=False, elem_classes="accordion-box"):
386
+ seed = gr.Slider(label="🎲 Seed", minimum=0, maximum=MAX_SEED, step=1, value=42)
387
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
388
 
389
  with gr.Row():
390
  width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
 
394
  num_inference_steps = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=50)
395
  guidance_scale = gr.Slider(label="Guidance", minimum=0.0, maximum=10.0, step=0.1, value=1.5)
396
 
397
+ # Right - Output
398
+ with gr.Column(elem_classes="output-col"):
399
+ result = gr.Image(label="Result", show_label=False, elem_classes="result-box")
400
 
401
  input_images.upload(
402
  fn=update_dimensions_from_image,