comrender commited on
Commit
3419fb9
Β·
verified Β·
1 Parent(s): 8a71554

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -28
app.py CHANGED
@@ -281,7 +281,7 @@ def enhance_image(
281
  gr.Info(f"πŸ“ Resizing output to target size: {w_original * upscale_factor}x{h_original * upscale_factor}")
282
  image = image.resize((w_original * upscale_factor, h_original * upscale_factor), resample=Image.LANCZOS)
283
 
284
- return [true_input_image, image], seed, generated_caption if use_generated_caption else ""
285
 
286
 
287
  # Create Gradio interface
@@ -386,20 +386,6 @@ with gr.Blocks(css=css, title="🎨 AI Image Upscaler - Florence-2 + FLUX") as d
386
  height=600, # Made larger
387
  elem_id="result_slider"
388
  )
389
-
390
- with gr.Row():
391
- output_seed = gr.Number(
392
- label="Used Seed",
393
- precision=0,
394
- interactive=False
395
- )
396
-
397
- generated_caption_output = gr.Textbox(
398
- label="Generated Caption",
399
- placeholder="AI-generated caption will appear here...",
400
- lines=3,
401
- interactive=False
402
- )
403
 
404
  # Event handler
405
  enhance_btn.click(
@@ -415,20 +401,8 @@ with gr.Blocks(css=css, title="🎨 AI Image Upscaler - Florence-2 + FLUX") as d
415
  use_generated_caption,
416
  custom_prompt,
417
  ],
418
- outputs=[result_slider, output_seed, generated_caption_output]
419
  )
420
-
421
- gr.HTML("""
422
- <div style="margin-top: 2rem; padding: 1rem; background: #f0f0f0; border-radius: 8px;">
423
- <h4>πŸ’‘ How it works:</h4>
424
- <ol>
425
- <li><strong>Florence-2</strong> analyzes your image and generates a detailed caption</li>
426
- <li>Initial upscale with LANCZOS interpolation (or ESRGAN if installed)</li>
427
- <li><strong>FLUX Img2Img</strong> upscales the upscaled image with tiled AI diffusion guided by the caption</li>
428
- </ol>
429
- <p><strong>Note:</strong> Output limited to 8192x8192 pixels total budget. Tiling enables larger sizes.</p>
430
- </div>
431
- """)
432
 
433
  # Custom CSS for slider
434
  gr.HTML("""
@@ -444,6 +418,19 @@ with gr.Blocks(css=css, title="🎨 AI Image Upscaler - Florence-2 + FLUX") as d
444
  }
445
  </style>
446
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
447
 
448
  if __name__ == "__main__":
449
  demo.queue().launch(share=True, server_name="0.0.0.0", server_port=7860)
 
281
  gr.Info(f"πŸ“ Resizing output to target size: {w_original * upscale_factor}x{h_original * upscale_factor}")
282
  image = image.resize((w_original * upscale_factor, h_original * upscale_factor), resample=Image.LANCZOS)
283
 
284
+ return [true_input_image, image]
285
 
286
 
287
  # Create Gradio interface
 
386
  height=600, # Made larger
387
  elem_id="result_slider"
388
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
 
390
  # Event handler
391
  enhance_btn.click(
 
401
  use_generated_caption,
402
  custom_prompt,
403
  ],
404
+ outputs=[result_slider]
405
  )
 
 
 
 
 
 
 
 
 
 
 
 
406
 
407
  # Custom CSS for slider
408
  gr.HTML("""
 
418
  }
419
  </style>
420
  """)
421
+
422
+ # JS to set slider default position to middle
423
+ gr.HTML("""
424
+ <script>
425
+ document.addEventListener('DOMContentLoaded', function() {
426
+ const sliderInput = document.querySelector('#result_slider input[type="range"]');
427
+ if (sliderInput) {
428
+ sliderInput.value = 50;
429
+ sliderInput.dispatchEvent(new Event('input'));
430
+ }
431
+ });
432
+ </script>
433
+ """)
434
 
435
  if __name__ == "__main__":
436
  demo.queue().launch(share=True, server_name="0.0.0.0", server_port=7860)