HAL1993 commited on
Commit
0e19a12
·
verified ·
1 Parent(s): d8fd238

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +113 -28
app.py CHANGED
@@ -148,6 +148,21 @@ def create_demo():
148
  gr.HTML("""
149
  <style>
150
  @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700&display=swap');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  body {
152
  background: #000000 !important;
153
  color: #FFFFFF !important;
@@ -189,24 +204,26 @@ def create_demo():
189
  justify-content: center;
190
  background: #000000 !important;
191
  color: #FFFFFF !important;
 
192
  }
193
  #input_column {
194
  background: #000000 !important;
195
- border: 1px solid #FFFFFF !important;
196
  border-radius: 8px;
197
  padding: 1rem !important;
198
- box-shadow: 0 0 10px rgba(255, 255, 255, 0.3); /* Subtle white glow */
199
  width: 100% !important;
200
  max-width: 100vw !important;
201
  box-sizing: border-box !important;
202
  color: #FFFFFF !important;
 
203
  }
204
  h1 {
205
  font-size: 5rem;
206
  font-weight: 700;
207
  text-align: center;
208
  color: #FFFFFF !important;
209
- text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
210
  margin: 0 auto 0.5rem auto;
211
  display: block;
212
  max-width: 100%;
@@ -234,18 +251,35 @@ def create_demo():
234
  max-width: 100vw !important;
235
  min-height: 500px;
236
  height: auto;
237
- border: 1px solid #FFFFFF !important;
238
  border-radius: 4px;
239
  box-sizing: border-box !important;
240
  background: #000000 !important;
241
- box-shadow: 0 0 10px rgba(255, 255, 255, 0.3); /* Subtle white glow */
242
  position: relative;
243
  color: #FFFFFF !important;
 
244
  }
245
  .image-container img {
246
- width: 100%;
247
  height: auto;
248
  box-sizing: border-box !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
250
  .image-container.processing {
251
  background: #000000 !important;
@@ -269,36 +303,37 @@ def create_demo():
269
  input, textarea {
270
  background: #000000 !important;
271
  color: #FFFFFF !important;
272
- border: 1px solid #FFFFFF !important;
273
  border-radius: 4px;
274
  padding: 0.5rem;
275
  width: 100% !important;
276
  max-width: 100vw !important;
277
  box-sizing: border-box !important;
278
- display: block;
279
  }
280
  input:hover, textarea:hover {
281
- box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
282
  transition: box-shadow 0.3s;
283
  }
284
  .gr-button-primary {
285
- background: #000000 !important;
 
 
286
  color: #FFFFFF !important;
287
- border: 1px solid #FFFFFF !important;
288
  border-radius: 6px;
289
  padding: 0.75rem 1.5rem;
290
  font-size: 1.1rem;
291
  font-weight: 600;
292
- box-shadow: 0 0 8px rgba(0, 255, 128, 0.3); /* Greenish glow */
293
  transition: box-shadow 0.3s, transform 0.3s;
294
  width: 100% !important;
295
  max-width: 100vw !important;
296
  min-height: 48px;
297
  cursor: pointer;
298
- display: block;
299
  }
300
  .gr-button-primary:hover {
301
- box-shadow: 0 0 12px rgba(0, 255, 128, 0.5); /* Stronger greenish glow */
 
302
  transform: scale(1.05);
303
  }
304
  button[aria-label="Fullscreen"], button[aria-label="Fullscreen"]:hover,
@@ -310,15 +345,15 @@ def create_demo():
310
  transform-origin: top right;
311
  background: #000000 !important;
312
  color: #FFFFFF !important;
313
- border: 1px solid #FFFFFF !important;
314
  border-radius: 4px;
315
  padding: 0.4rem !important;
316
  margin: 0.5rem !important;
317
- box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
318
  transition: box-shadow 0.3s;
319
  }
320
  button[aria-label="Download"]:hover {
321
- box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
322
  }
323
  .progress-text, .gr-progress {
324
  display: none !important;
@@ -326,6 +361,12 @@ def create_demo():
326
  footer, .gr-button-secondary {
327
  display: none !important;
328
  }
 
 
 
 
 
 
329
  @media (max-width: 768px) {
330
  h1 {
331
  font-size: 4rem;
@@ -336,14 +377,17 @@ def create_demo():
336
  .gr-button-primary {
337
  padding: 0.6rem 1rem;
338
  font-size: 1rem;
339
- box-shadow: 0 0 6px rgba(0, 255, 128, 0.3);
 
340
  }
341
  .gr-button-primary:hover {
342
- box-shadow: 0 0 10px rgba(0, 255, 128, 0.5);
 
343
  }
344
  .image-container {
345
  min-height: 300px;
346
- box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
 
347
  }
348
  .image-container.processing::before {
349
  font-size: 0.9rem;
@@ -353,13 +397,13 @@ def create_demo():
353
  }
354
  </style>
355
  <script>
356
- // Debug: Log container dimensions and glow properties
357
  document.addEventListener('DOMContentLoaded', () => {
358
  const containers = document.querySelectorAll('#general_items, #input_column, .image-container');
359
  containers.forEach(container => {
360
  const width = container.offsetWidth;
361
  const style = window.getComputedStyle(container);
362
- console.log(`Container ${container.id || container.className}: width=${width}px, box-shadow=${style.boxShadow} (Viewport: ${window.innerWidth}px)`);
363
  container.setAttribute('data-width', `${width}px`);
364
  });
365
  const processingText = document.querySelectorAll('.image-container.processing::before');
@@ -370,11 +414,52 @@ def create_demo():
370
  const editButton = document.querySelector('.gr-button-primary');
371
  if (editButton) {
372
  const style = window.getComputedStyle(editButton);
373
- console.log(`Edit button: box-shadow=${style.boxShadow}`);
374
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  // Toggle processing state
376
  const runButton = document.querySelector('.gr-button-primary');
377
- const resultImage = document.querySelector('.image-container:nth-child(4)'); // Adjusted for new order
378
  if (runButton && resultImage) {
379
  runButton.addEventListener('click', () => {
380
  resultImage.classList.add('processing');
@@ -400,21 +485,21 @@ def create_demo():
400
  input_image = gr.Image(
401
  label="Input Image",
402
  type="pil",
403
- interactive=True,
404
  show_download_button=False,
405
  show_share_button=False,
 
406
  elem_classes=["gradio-component", "image-container"]
407
  )
408
  prompt = gr.Textbox(
409
  label="Prompt",
410
- placeholder="Describe the edit instruction",
411
  lines=3,
412
- elem_classes="gradio-component"
413
  )
414
  run_button = gr.Button(
415
  "Edit!",
416
  variant="primary",
417
- elem_classes="gr-button-primary"
418
  )
419
  result_image = gr.Image(
420
  label="Result Image",
 
148
  gr.HTML("""
149
  <style>
150
  @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700&display=swap');
151
+ @keyframes glow {
152
+ 0% { box-shadow: 0 0 14px rgba(0, 255, 128, 0.5); }
153
+ 50% { box-shadow: 0 0 14px rgba(0, 255, 128, 0.7); }
154
+ 100% { box-shadow: 0 0 14px rgba(0, 255, 128, 0.5); }
155
+ }
156
+ @keyframes glow-hover {
157
+ 0% { box-shadow: 0 0 20px rgba(0, 255, 128, 0.7); }
158
+ 50% { box-shadow: 0 0 20px rgba(0, 255, 128, 0.9); }
159
+ 100% { box-shadow: 0 0 20px rgba(0, 255, 128, 0.7); }
160
+ }
161
+ @keyframes slide {
162
+ 0% { background-position: 0% 50%; }
163
+ 50% { background-position: 100% 50%; }
164
+ 100% { background-position: 0% 50%; }
165
+ }
166
  body {
167
  background: #000000 !important;
168
  color: #FFFFFF !important;
 
204
  justify-content: center;
205
  background: #000000 !important;
206
  color: #FFFFFF !important;
207
+ /* border: 1px solid blue; */ /* Debug */
208
  }
209
  #input_column {
210
  background: #000000 !important;
211
+ border: none !important; /* Invisible outer border */
212
  border-radius: 8px;
213
  padding: 1rem !important;
214
+ box-shadow: 0 0 10px rgba(255, 255, 255, 0.3) !important; /* White glow */
215
  width: 100% !important;
216
  max-width: 100vw !important;
217
  box-sizing: border-box !important;
218
  color: #FFFFFF !important;
219
+ /* border: 1px solid red; */ /* Debug */
220
  }
221
  h1 {
222
  font-size: 5rem;
223
  font-weight: 700;
224
  text-align: center;
225
  color: #FFFFFF !important;
226
+ text-shadow: 0 0 8px rgba(255, 255, 255, 0.3) !important;
227
  margin: 0 auto 0.5rem auto;
228
  display: block;
229
  max-width: 100%;
 
251
  max-width: 100vw !important;
252
  min-height: 500px;
253
  height: auto;
254
+ border: 0.5px solid #FFFFFF !important; /* Thinner white border */
255
  border-radius: 4px;
256
  box-sizing: border-box !important;
257
  background: #000000 !important;
258
+ box-shadow: 0 0 10px rgba(255, 255, 255, 0.3) !important; /* White glow */
259
  position: relative;
260
  color: #FFFFFF !important;
261
+ /* border: 1px solid green; */ /* Debug */
262
  }
263
  .image-container img {
264
+ width: 100% !important;
265
  height: auto;
266
  box-sizing: border-box !important;
267
+ display: block !important;
268
+ }
269
+ /* Exhaustive selectors to hide upload/webcam/paste toolbar */
270
+ .image-container[aria-label="Input Image"] .file-upload,
271
+ .image-container[aria-label="Input Image"] .file-preview,
272
+ .image-container[aria-label="Input Image"] .image-actions,
273
+ .image-container[aria-label="Input Image"] .gr-file-upload,
274
+ .image-container[aria-label="Input Image"] .gr-file,
275
+ .image-container[aria-label="Input Image"] .gr-actions,
276
+ .image-container[aria-label="Input Image"] .gr-upload-button,
277
+ .image-container[aria-label="Input Image"] .gr-image-toolbar,
278
+ .image-container[aria-label="Input Image"] .gr-file-actions,
279
+ .image-container[aria-label="Input Image"] .gr-upload-options,
280
+ div[aria-label="Input Image"] > div > div:not(.image-container),
281
+ div[aria-label="Input Image"] .gr-button {
282
+ display: none !important; /* Force hide all toolbar elements */
283
  }
284
  .image-container.processing {
285
  background: #000000 !important;
 
303
  input, textarea {
304
  background: #000000 !important;
305
  color: #FFFFFF !important;
306
+ border: 1px solid #FFFFFF !important; /* White border */
307
  border-radius: 4px;
308
  padding: 0.5rem;
309
  width: 100% !important;
310
  max-width: 100vw !important;
311
  box-sizing: border-box !important;
 
312
  }
313
  input:hover, textarea:hover {
314
+ box-shadow: 0 0 8px rgba(255, 255, 255, 0.3) !important;
315
  transition: box-shadow 0.3s;
316
  }
317
  .gr-button-primary {
318
+ background: linear-gradient(90deg, rgba(0, 255, 128, 0.3), rgba(0, 200, 100, 0.3), rgba(0, 255, 128, 0.3)) !important;
319
+ background-size: 200% 100%;
320
+ animation: slide 4s ease-in-out infinite, glow 3s ease-in-out infinite;
321
  color: #FFFFFF !important;
322
+ border: 1px solid #FFFFFF !important; /* White border */
323
  border-radius: 6px;
324
  padding: 0.75rem 1.5rem;
325
  font-size: 1.1rem;
326
  font-weight: 600;
327
+ box-shadow: 0 0 14px rgba(0, 255, 128, 0.7) !important; /* Breathing green glow */
328
  transition: box-shadow 0.3s, transform 0.3s;
329
  width: 100% !important;
330
  max-width: 100vw !important;
331
  min-height: 48px;
332
  cursor: pointer;
 
333
  }
334
  .gr-button-primary:hover {
335
+ box-shadow: 0 0 20px rgba(0, 255, 128, 0.9) !important; /* Stronger glow */
336
+ animation: slide 4s ease-in-out infinite, glow-hover 3s ease-in-out infinite;
337
  transform: scale(1.05);
338
  }
339
  button[aria-label="Fullscreen"], button[aria-label="Fullscreen"]:hover,
 
345
  transform-origin: top right;
346
  background: #000000 !important;
347
  color: #FFFFFF !important;
348
+ border: 1px solid #FFFFFF !important; /* White border */
349
  border-radius: 4px;
350
  padding: 0.4rem !important;
351
  margin: 0.5rem !important;
352
+ box-shadow: 0 0 8px rgba(255, 255, 255, 0.3) !important;
353
  transition: box-shadow 0.3s;
354
  }
355
  button[aria-label="Download"]:hover {
356
+ box-shadow: 0 0 12px rgba(255, 255, 255, 0.5) !important;
357
  }
358
  .progress-text, .gr-progress {
359
  display: none !important;
 
361
  footer, .gr-button-secondary {
362
  display: none !important;
363
  }
364
+ .gr-group {
365
+ background: #000000 !important;
366
+ border: none !important;
367
+ width: 100% !important;
368
+ max-width: 100vw !important;
369
+ }
370
  @media (max-width: 768px) {
371
  h1 {
372
  font-size: 4rem;
 
377
  .gr-button-primary {
378
  padding: 0.6rem 1rem;
379
  font-size: 1rem;
380
+ box-shadow: 0 0 10px rgba(0, 255, 128, 0.7) !important;
381
+ animation: slide 4s ease-in-out infinite, glow 3s ease-in-out infinite;
382
  }
383
  .gr-button-primary:hover {
384
+ box-shadow: 0 0 12px rgba(0, 255, 128, 0.9) !important;
385
+ animation: slide 4s ease-in-out infinite, glow-hover 3s ease-in-out infinite;
386
  }
387
  .image-container {
388
  min-height: 300px;
389
+ box-shadow: 0 0 8px rgba(255, 255, 255, 0.3) !important;
390
+ border: 0.5px solid #FFFFFF !important; /* Thinner white border */
391
  }
392
  .image-container.processing::before {
393
  font-size: 0.9rem;
 
397
  }
398
  </style>
399
  <script>
400
+ // Debug: Log container dimensions, glow, background, border, and toolbar visibility
401
  document.addEventListener('DOMContentLoaded', () => {
402
  const containers = document.querySelectorAll('#general_items, #input_column, .image-container');
403
  containers.forEach(container => {
404
  const width = container.offsetWidth;
405
  const style = window.getComputedStyle(container);
406
+ console.log(`Container ${container.id || container.className}: width=${width}px, box-shadow=${style.boxShadow}, background=${style.background}, border=${style.border} (Viewport: ${window.innerWidth}px)`);
407
  container.setAttribute('data-width', `${width}px`);
408
  });
409
  const processingText = document.querySelectorAll('.image-container.processing::before');
 
414
  const editButton = document.querySelector('.gr-button-primary');
415
  if (editButton) {
416
  const style = window.getComputedStyle(editButton);
417
+ console.log(`Edit button: box-shadow=${style.boxShadow}, background=${style.background}, border=${style.border}, animation=${style.animation}, background-position=${style.backgroundPosition}`);
418
  }
419
+ // Log all toolbar elements
420
+ const toolbarSelectors = [
421
+ '.image-container[aria-label="Input Image"] .file-upload',
422
+ '.image-container[aria-label="Input Image"] .file-preview',
423
+ '.image-container[aria-label="Input Image"] .image-actions',
424
+ '.image-container[aria-label="Input Image"] .gr-file-upload',
425
+ '.image-container[aria-label="Input Image"] .gr-file',
426
+ '.image-container[aria-label="Input Image"] .gr-actions',
427
+ '.image-container[aria-label="Input Image"] .gr-upload-button',
428
+ '.image-container[aria-label="Input Image"] .gr-image-toolbar',
429
+ '.image-container[aria-label="Input Image"] .gr-file-actions',
430
+ '.image-container[aria-label="Input Image"] .gr-upload-options',
431
+ 'div[aria-label="Input Image"] > div > div:not(.image-container)',
432
+ 'div[aria-label="Input Image"] .gr-button'
433
+ ];
434
+ toolbarSelectors.forEach(selector => {
435
+ const elements = document.querySelectorAll(selector);
436
+ elements.forEach(el => {
437
+ const style = window.getComputedStyle(el);
438
+ console.log(`Toolbar element ${selector}: display=${style.display}, class=${el.className}`);
439
+ });
440
+ });
441
+ // Force hide any residual toolbar elements
442
+ const toolbars = document.querySelectorAll(
443
+ '.image-container[aria-label="Input Image"] > div > div:not(.image-container), ' +
444
+ '.image-container[aria-label="Input Image"] .file-upload, ' +
445
+ '.image-container[aria-label="Input Image"] .file-preview, ' +
446
+ '.image-container[aria-label="Input Image"] .image-actions, ' +
447
+ '.image-container[aria-label="Input Image"] .gr-file-upload, ' +
448
+ '.image-container[aria-label="Input Image"] .gr-file, ' +
449
+ '.image-container[aria-label="Input Image"] .gr-actions, ' +
450
+ '.image-container[aria-label="Input Image"] .gr-upload-button, ' +
451
+ '.image-container[aria-label="Input Image"] .gr-image-toolbar, ' +
452
+ '.image-container[aria-label="Input Image"] .gr-file-actions, ' +
453
+ '.image-container[aria-label="Input Image"] .gr-upload-options, ' +
454
+ 'div[aria-label="Input Image"] .gr-button'
455
+ );
456
+ toolbars.forEach(toolbar => {
457
+ toolbar.style.display = 'none';
458
+ console.log(`Forced hide toolbar: ${toolbar.className}`);
459
+ });
460
  // Toggle processing state
461
  const runButton = document.querySelector('.gr-button-primary');
462
+ const resultImage = document.querySelector('.image-container[aria-label="Result Image"]');
463
  if (runButton && resultImage) {
464
  runButton.addEventListener('click', () => {
465
  resultImage.classList.add('processing');
 
485
  input_image = gr.Image(
486
  label="Input Image",
487
  type="pil",
488
+ sources=["upload"], # Restrict to file upload only
489
  show_download_button=False,
490
  show_share_button=False,
491
+ interactive=True,
492
  elem_classes=["gradio-component", "image-container"]
493
  )
494
  prompt = gr.Textbox(
495
  label="Prompt",
 
496
  lines=3,
497
+ elem_classes=["gradio-component"]
498
  )
499
  run_button = gr.Button(
500
  "Edit!",
501
  variant="primary",
502
+ elem_classes=["gradio-component", "gr-button-primary"]
503
  )
504
  result_image = gr.Image(
505
  label="Result Image",