salso commited on
Commit
6c02d81
โ€ข
1 Parent(s): e5f0808

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +123 -99
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import math
3
  import gradio as gr
@@ -280,72 +281,8 @@ class Stage(Enum):
280
  SECOND_STAGE = "refiner"
281
  FULL = "full"
282
 
283
- # CSS for styling
284
- css = """
285
- /* General Styles */
286
- body {
287
- font-family: Arial, sans-serif;
288
- background-color: #f4f4f9;
289
- margin: 0;
290
- padding: 0;
291
- display: flex;
292
- flex-direction: column;
293
- justify-content: center;
294
- align-items: center;
295
- min-height: 100vh;
296
- color: #333;
297
- }
298
-
299
- .custom-button {
300
- background: linear-gradient(271.15deg, #00C7E2 0.27%, #00CC6A 48.52%, #70FF00 102.07%);
301
- font-size: 30px;
302
- color: white;
303
- padding: 10px 20px;
304
- border: none;
305
- border-radius: 5px;
306
- cursor: pointer;
307
- transition: opacity 0.3s ease;
308
- width: 100%;
309
- max-width: 250px;
310
- }
311
-
312
- .custom-button:hover {
313
- opacity: 0.8;
314
- }
315
-
316
- .custom-title {
317
- font-size: 36px;
318
- background: linear-gradient(271.15deg, #00C7E2 0.27%, #12C06D 102.07%);
319
- -webkit-background-clip: text;
320
- -webkit-text-fill-color: transparent;
321
- font-weight: bold;
322
  text-align: center;
323
- margin-bottom: 20px;
324
- width: 100%;
325
- }
326
-
327
- .container, .example {
328
- width: 100%;
329
- padding: 0 1rem;
330
- box-sizing: border-box;
331
- }
332
-
333
- h1, h2 {
334
- color: #222222;
335
- }
336
-
337
- a {
338
- color: #4a90e2;
339
- text-decoration: none;
340
- font-weight: bold;
341
- }
342
-
343
- a:hover {
344
- text-decoration: underline;
345
- }
346
-
347
- .emoji {
348
- font-size: 1.5em;
349
  }
350
 
351
  #share-btn-container {
@@ -355,8 +292,8 @@ a:hover {
355
  justify-content: center;
356
  align-items: center;
357
  border-radius: 9999px !important;
358
- max-width: 100%;
359
- margin: 1rem auto;
360
  }
361
 
362
  #share-btn-container > div {
@@ -404,7 +341,62 @@ a:hover {
404
  background: #1565c0;
405
  }
406
 
407
- /* Responsive Adjustments */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  @media (max-width: 768px) {
409
  .custom-button {
410
  font-size: 20px;
@@ -415,7 +407,11 @@ a:hover {
415
  font-size: 28px;
416
  }
417
 
418
- h1, h2 {
 
 
 
 
419
  font-size: 24px;
420
  }
421
  }
@@ -430,7 +426,11 @@ a:hover {
430
  font-size: 22px;
431
  }
432
 
433
- h1, h2 {
 
 
 
 
434
  font-size: 20px;
435
  }
436
 
@@ -439,64 +439,72 @@ a:hover {
439
  padding: 0.5rem;
440
  }
441
  }
442
- """
443
-
444
- # Function to process image generation
445
- def process_generate(fore, prompt, intensity, mode, refprompt, isrmbg):
446
- # Your function logic here
447
- return fore
448
-
449
- # Define the layout using Gradio
450
  block = gr.Blocks(css=css, title="## F.ai Fuzer").queue()
451
  with block:
452
- gr.HTML('<meta name="viewport" content="width=device-width, initial-scale=1.0">')
453
-
454
  gr.HTML('''
 
455
  <div class="container">
456
  <center><h1 class="custom-title">Fotographer.ai Fuzer v0.1: Transcending image Generation Control๐ŸŽจ</h1></center>
457
- <h2>Control Your Creativity with Unmatched Precision:</h2>
458
  <p>Fotographer.ai Fuzer v0.1 empowers you to seamlessly blend foreground elements with any background, while maintaining the shape and style consistency of the foreground. This tool transcends traditional image generation methods by giving you unprecedented control over the final output.</p>
 
459
  <h2>Step-by-Step Instructions</h2>
460
  <p>Follow these instructions to control the generation of backgrounds while keeping the foreground's shape and style consistent:</p>
461
  <ul>
462
- <li><span class="emoji">๐Ÿ“</span> <strong>Step 1: Describe the Background</strong>
 
 
463
  <p>Start by providing a detailed description of the background you want to create.</p>
464
  <div class="example">
465
  <p><strong>Example:</strong> "A Perfume Bottle nestled on a crystalline cliff of glistening snow, overlooking a serene, moonlit valley."</p>
466
  </div>
467
  </li>
468
- <li><span class="emoji">๐Ÿ’ก</span> <strong>Step 2: Describe the Foreground</strong>
 
 
469
  <p>Next, describe the texture, lighting, and style of the foreground element.</p>
470
  <div class="example">
471
  <p><strong>Example:</strong> "A transparent glass perfume bottle, vibrant, sunset lighting reflecting off its surface."</p>
472
  </div>
473
  </li>
474
- <li><span class="emoji">๐ŸŽš๏ธ</span> <strong>Step 3: Adjust the Intensity</strong>
 
 
475
  <p>Decide how much change you want to apply to the image. Adjust the intensity to balance between keeping consistency and introducing new elements.</p>
476
  </li>
477
  </ul>
478
- </div>
479
- ''')
 
 
480
 
481
- gr.HTML('<center><h2><a href="https://api-dashboard.fotographer.ai/login.html">๐Ÿ”— Check out our API!</a></h2></center>')
482
-
483
  with gr.Row():
484
  gr.Markdown("### F.ai Fuzer: Real Composite Photography in 2 minutes!")
485
-
486
  with gr.Row():
487
  fore = gr.Image(image_mode='RGBA', type="pil", label="Foreground Image", height=400, width=400)
488
  with gr.Column():
489
- result_gallery = gr.Image(label='Output')
490
-
491
  with gr.Row():
492
  prompt = gr.Textbox(label="Prompt")
493
  with gr.Column():
494
  refprompt = gr.Textbox(label="Refiner Prompt")
495
-
496
  with gr.Row():
497
- mode = gr.Radio(choices=[e.value for e in Stage], value=Stage.FULL.value, label="Generation Mode", type='value')
 
 
498
  mode.change(fn=update_value, inputs=mode, outputs=mode)
499
-
 
 
 
 
 
 
 
 
 
500
  with gr.Row():
501
  intensity = gr.Slider(label="Refiner Strength", minimum=1.0, maximum=7.0, value=3.0, step=0.5)
502
  intensity.change(fn=update_value, inputs=intensity, outputs=intensity)
@@ -505,6 +513,7 @@ with block:
505
  generate_button = gr.Button(value="Generate", elem_classes="custom-button")
506
 
507
  gr.HTML('''
 
508
  <div class="container">
509
  <h2>Features:</h2>
510
  <ul>
@@ -513,10 +522,12 @@ with block:
513
  <li>๐ŸŽจ <strong>Custom Background Control:</strong> Choose or generate backgrounds that perfectly match your creative vision.</li>
514
  <li>โš™๏ธ <strong>Easy Integration:</strong> Integrates smoothly with your existing workflow and tools.</li>
515
  </ul>
516
- ''')
517
-
518
- gr.HTML('<center><h2><a href="https://fotographer.ai/">๐Ÿ”— Check Out our other Projects Here!</a></h2></center>')
519
-
 
 
520
  with gr.Row():
521
  dummy_image_for_outputs = gr.Image(visible=False, label='Result', height=400, width=400)
522
  gr.Examples(
@@ -525,10 +536,23 @@ with block:
525
  inputs=[
526
  fore, prompt, intensity, mode, refprompt, isrmbg, dummy_image_for_outputs
527
  ]
 
528
  )
 
 
 
 
 
 
 
 
 
 
 
529
 
530
  ins = [fore, prompt, intensity, mode, refprompt, isrmbg]
531
  generate_button.click(fn=process_generate, inputs=ins, outputs=[result_gallery])
532
 
533
- block.launch()
534
 
 
 
 
1
+ #version 2
2
  import os
3
  import math
4
  import gradio as gr
 
281
  SECOND_STAGE = "refiner"
282
  FULL = "full"
283
 
284
+ css="""#disp_image {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  text-align: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  }
287
 
288
  #share-btn-container {
 
292
  justify-content: center;
293
  align-items: center;
294
  border-radius: 9999px !important;
295
+ max-width: 13rem;
296
+ margin-left: auto;
297
  }
298
 
299
  #share-btn-container > div {
 
341
  background: #1565c0;
342
  }
343
 
344
+ body {
345
+ font-family: Arial, sans-serif;
346
+ background-color: #f4f4f9;
347
+ margin: 0;
348
+ padding: 0;
349
+ display: flex;
350
+ flex-direction: column;
351
+ justify-content: center;
352
+ align-items: center;
353
+ min-height: 100vh;
354
+ color: #333;
355
+ }
356
+
357
+ .custom-button {
358
+ background: linear-gradient(271.15deg, #00C7E2 0.27%, #00CC6A 48.52%, #70FF00 102.07%);
359
+ font-size: 30px;
360
+ color: white;
361
+ padding: 10px 20px;
362
+ border: none;
363
+ border-radius: 5px;
364
+ cursor: pointer;
365
+ transition: opacity 0.3s ease;
366
+ }
367
+
368
+ .custom-button:hover {
369
+ opacity: 0.8;
370
+ }
371
+
372
+ .custom-title {
373
+ font-size: 36px;
374
+ background: linear-gradient(271.15deg, #00C7E2 0.27%, #12C06D 102.07%);
375
+ -webkit-background-clip: text;
376
+ -webkit-text-fill-color: transparent;
377
+ font-weight: bold;
378
+ text-align: center;
379
+ margin-bottom: 20px;
380
+ }
381
+
382
+ h1 {
383
+ color: #222222;
384
+ }
385
+
386
+ a {
387
+ color: #4a90e2;
388
+ text-decoration: none;
389
+ font-weight: bold;
390
+ }
391
+
392
+ a:hover {
393
+ text-decoration: underline;
394
+ }
395
+
396
+ .emoji {
397
+ font-size: 1.5em;
398
+ }
399
+
400
  @media (max-width: 768px) {
401
  .custom-button {
402
  font-size: 20px;
 
407
  font-size: 28px;
408
  }
409
 
410
+ #disp_image, .container {
411
+ padding: 0 1rem;
412
+ }
413
+
414
+ h1 {
415
  font-size: 24px;
416
  }
417
  }
 
426
  font-size: 22px;
427
  }
428
 
429
+ .container {
430
+ padding: 0 0.5rem;
431
+ }
432
+
433
+ h1 {
434
  font-size: 20px;
435
  }
436
 
 
439
  padding: 0.5rem;
440
  }
441
  }
442
+ """
 
 
 
 
 
 
 
443
  block = gr.Blocks(css=css, title="## F.ai Fuzer").queue()
444
  with block:
445
+
 
446
  gr.HTML('''
447
+
448
  <div class="container">
449
  <center><h1 class="custom-title">Fotographer.ai Fuzer v0.1: Transcending image Generation Control๐ŸŽจ</h1></center>
450
+ <h2>Control Your Creativity with Unmatched Precision: </h2>
451
  <p>Fotographer.ai Fuzer v0.1 empowers you to seamlessly blend foreground elements with any background, while maintaining the shape and style consistency of the foreground. This tool transcends traditional image generation methods by giving you unprecedented control over the final output.</p>
452
+
453
  <h2>Step-by-Step Instructions</h2>
454
  <p>Follow these instructions to control the generation of backgrounds while keeping the foreground's shape and style consistent:</p>
455
  <ul>
456
+ <li>
457
+ <span class="emoji">๐Ÿ“</span>
458
+ <strong>Step 1: Describe the Background</strong>
459
  <p>Start by providing a detailed description of the background you want to create.</p>
460
  <div class="example">
461
  <p><strong>Example:</strong> "A Perfume Bottle nestled on a crystalline cliff of glistening snow, overlooking a serene, moonlit valley."</p>
462
  </div>
463
  </li>
464
+ <li>
465
+ <span class="emoji">๐Ÿ’ก</span>
466
+ <strong>Step 2: Describe the Foreground</strong>
467
  <p>Next, describe the texture, lighting, and style of the foreground element.</p>
468
  <div class="example">
469
  <p><strong>Example:</strong> "A transparent glass perfume bottle, vibrant, sunset lighting reflecting off its surface."</p>
470
  </div>
471
  </li>
472
+ <li>
473
+ <span class="emoji">๐ŸŽš๏ธ</span>
474
+ <strong>Step 3: Adjust the Intensity</strong>
475
  <p>Decide how much change you want to apply to the image. Adjust the intensity to balance between keeping consistency and introducing new elements.</p>
476
  </li>
477
  </ul>
478
+ </div>
479
+ ''')
480
+ gr.HTML("""
481
+ <center><h2><a href="https://api-dashboard.fotographer.ai/login.html">๐Ÿ”— Check out our API!</a></h2></center>""")
482
 
 
 
483
  with gr.Row():
484
  gr.Markdown("### F.ai Fuzer: Real Composite Photography in 2 minutes!")
 
485
  with gr.Row():
486
  fore = gr.Image(image_mode='RGBA', type="pil", label="Foreground Image", height=400, width=400)
487
  with gr.Column():
488
+ result_gallery = gr.Image(label='Output') #gr.Gallery(height=400, object_fit='contain', label='Outputs')
 
489
  with gr.Row():
490
  prompt = gr.Textbox(label="Prompt")
491
  with gr.Column():
492
  refprompt = gr.Textbox(label="Refiner Prompt")
 
493
  with gr.Row():
494
+ mode = gr.Radio(choices=[e.value for e in Stage],
495
+ value=Stage.FULL.value,
496
+ label="Generation Mode", type='value')
497
  mode.change(fn=update_value, inputs=mode, outputs=mode)
498
+
499
+ with gr.Column():
500
+ gr.HTML('''
501
+ <div class="container">
502
+ <h1>๐Ÿš€ For more freedom of usage, check out our API</h1>
503
+ <p>๐Ÿ‘ค You can test with free credits:</p>
504
+ <h2><a href="https://api-dashboard.fotographer.ai/login.html">๐Ÿ”— API Dashboard</a></h2>
505
+ </div>
506
+ ''')
507
+
508
  with gr.Row():
509
  intensity = gr.Slider(label="Refiner Strength", minimum=1.0, maximum=7.0, value=3.0, step=0.5)
510
  intensity.change(fn=update_value, inputs=intensity, outputs=intensity)
 
513
  generate_button = gr.Button(value="Generate", elem_classes="custom-button")
514
 
515
  gr.HTML('''
516
+
517
  <div class="container">
518
  <h2>Features:</h2>
519
  <ul>
 
522
  <li>๐ŸŽจ <strong>Custom Background Control:</strong> Choose or generate backgrounds that perfectly match your creative vision.</li>
523
  <li>โš™๏ธ <strong>Easy Integration:</strong> Integrates smoothly with your existing workflow and tools.</li>
524
  </ul>
525
+ </div>
526
+ ''')
527
+
528
+ gr.HTML("""
529
+ <center><h2><a href="https://fotographer.ai/">๐Ÿ”— Check Out our other Projects Here!</a></h2></center>""")
530
+
531
  with gr.Row():
532
  dummy_image_for_outputs = gr.Image(visible=False, label='Result', height=400, width=400)
533
  gr.Examples(
 
536
  inputs=[
537
  fore, prompt, intensity, mode, refprompt, isrmbg, dummy_image_for_outputs
538
  ]
539
+
540
  )
541
+ '''
542
+ with gr.Column():
543
+ dummy_image_for_outputs = gr.Image(visible=False, label='Result')
544
+ gr.Examples(
545
+ examples=outputs_list,
546
+ inputs=[dummy_image_for_outputs],
547
+
548
+ )
549
+ '''
550
+
551
+
552
 
553
  ins = [fore, prompt, intensity, mode, refprompt, isrmbg]
554
  generate_button.click(fn=process_generate, inputs=ins, outputs=[result_gallery])
555
 
 
556
 
557
+
558
+ block.launch()