muhammadsalmanalfaridzi commited on
Commit
0160002
β€’
1 Parent(s): 4c32a7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -5
app.py CHANGED
@@ -59,7 +59,7 @@ def remove_background_bria(input_path):
59
 
60
  return output_image
61
 
62
- # Fungsi untuk memproses gambar menggunakan prompt
63
  def text_to_image(prompt):
64
  os.makedirs("generated_images", exist_ok=True) # Ensure the directory exists
65
  image = sd_model(prompt).images[0] # Generate image using the model
@@ -425,11 +425,28 @@ def process(input_files, bg_method, watermark, canvas_size, output_format, bg_ch
425
  return [], None, "Error during processing"
426
 
427
  with gr.Blocks(theme="NoCrypt/miku@1.2.2") as iface:
428
- gr.Markdown("# Image Background Removal and Resizing with Optional Watermark")
429
- gr.Markdown("Choose to upload multiple images or a ZIP/RAR file, select the crop mode, optionally upload a watermark image, and choose the output format.")
 
 
 
 
 
 
 
 
430
 
431
  # Fitur Text to Image
432
- gr.Markdown("# Text to Image Feature")
 
 
 
 
 
 
 
 
 
433
  with gr.Row():
434
  prompt_input = gr.Textbox(label="Enter your prompt for image generation:")
435
  generate_button = gr.Button("Generate Image")
@@ -439,7 +456,16 @@ with gr.Blocks(theme="NoCrypt/miku@1.2.2") as iface:
439
  generate_button.click(text_to_image, inputs=prompt_input, outputs=[output_image, download_button])
440
 
441
  # Fitur Text Image to Image
442
- gr.Markdown("# Text Image to Image Feature")
 
 
 
 
 
 
 
 
 
443
  with gr.Row():
444
  input_image = gr.Image(label="Upload Image for Modification", type="pil")
445
  prompt_modification = gr.Textbox(label="Enter your prompt for modification:")
@@ -448,6 +474,9 @@ with gr.Blocks(theme="NoCrypt/miku@1.2.2") as iface:
448
  download_modified_button = gr.File(label="Download Modified Image", type="filepath")
449
 
450
  modify_button.click(text_image_to_image, inputs=[input_image, prompt_modification], outputs=[modified_output_image, download_modified_button])
 
 
 
451
 
452
  with gr.Row():
453
  input_files = gr.File(label="Upload Image or ZIP/RAR file", file_types=[".zip", ".rar", "image"], interactive=True)
@@ -481,4 +510,7 @@ with gr.Blocks(theme="NoCrypt/miku@1.2.2") as iface:
481
  process_button.click(process, inputs=[input_files, bg_method, watermark, canvas_size, output_format, bg_choice, custom_color, num_workers], outputs=[gallery_processed, output_zip, processing_time])
482
  gallery_processed.select(update_compare, outputs=[image_original, image_processed, original_ratio, processed_ratio])
483
 
 
 
 
484
  iface.launch(share=True)
 
59
 
60
  return output_image
61
 
62
+ # Function to process images using prompts
63
  def text_to_image(prompt):
64
  os.makedirs("generated_images", exist_ok=True) # Ensure the directory exists
65
  image = sd_model(prompt).images[0] # Generate image using the model
 
425
  return [], None, "Error during processing"
426
 
427
  with gr.Blocks(theme="NoCrypt/miku@1.2.2") as iface:
428
+ gr.Markdown("# 🎨 Creative Image Suite: Generate, Modify, and Enhance Your Visuals")
429
+ gr.Markdown("""
430
+ **Unlock your creativity with our comprehensive image processing tool! This suite offers three powerful features:**
431
+
432
+ 1. **✏️ Text to Image**: Transform your ideas into stunning visuals by simply entering a descriptive text prompt. Watch your imagination come to life!
433
+
434
+ 2. **πŸ–ΌοΈ Text Image to Image**: Enhance existing images by providing a text description of the modifications you want. Upload any image and specify the changes as you wish to create a unique masterpiece.
435
+
436
+ 3. **πŸ–ŒοΈ Image Background Removal and Resizing**: Effortlessly remove backgrounds from images, resize them, and even add watermarks (opitonal). Upload single images or zip files, choose your desired settings, and let our tool process everything seamlessly.
437
+ """)
438
 
439
  # Fitur Text to Image
440
+ gr.Markdown("## ✏️ Text to Image Feature")
441
+ gr.Markdown("""
442
+ **Example Prompts:**
443
+ - *A serene mountain landscape at sunset.*
444
+ - *A futuristic city skyline with flying cars.*
445
+ - *A whimsical forest filled with colorful mushrooms and fairies.*
446
+ - *A close-up of a vibrant butterfly resting on a flower.*
447
+
448
+ This feature allows you to create a new image based on a text description. Simply enter your idea in a sentence, and the system will generate an image that matches it.
449
+ """)
450
  with gr.Row():
451
  prompt_input = gr.Textbox(label="Enter your prompt for image generation:")
452
  generate_button = gr.Button("Generate Image")
 
456
  generate_button.click(text_to_image, inputs=prompt_input, outputs=[output_image, download_button])
457
 
458
  # Fitur Text Image to Image
459
+ gr.Markdown("## πŸ–ΌοΈ Text Image to Image Feature")
460
+ gr.Markdown("""
461
+ **Example Prompts:**
462
+ - *Change the sky to a starry night with a full moon.*
463
+ - *Add a rainbow across the horizon in this beach scene.*
464
+ - *Make the flowers in the garden bloom in shades of blue.*
465
+ - *Transform the cat's fur to a bright orange color.*
466
+
467
+ This feature lets you modify an existing image by adding a text description. Upload an image, specify what you want to change, and the system will alter the image accordingly.
468
+ """)
469
  with gr.Row():
470
  input_image = gr.Image(label="Upload Image for Modification", type="pil")
471
  prompt_modification = gr.Textbox(label="Enter your prompt for modification:")
 
474
  download_modified_button = gr.File(label="Download Modified Image", type="filepath")
475
 
476
  modify_button.click(text_image_to_image, inputs=[input_image, prompt_modification], outputs=[modified_output_image, download_modified_button])
477
+
478
+ gr.Markdown("## πŸ–ŒοΈ Image Background Removal and Resizing with Optional Watermark")
479
+ gr.Markdown("Choose to upload multiple images or a ZIP/RAR file, select the crop mode, optionally upload a watermark image, and choose the output format.")
480
 
481
  with gr.Row():
482
  input_files = gr.File(label="Upload Image or ZIP/RAR file", file_types=[".zip", ".rar", "image"], interactive=True)
 
510
  process_button.click(process, inputs=[input_files, bg_method, watermark, canvas_size, output_format, bg_choice, custom_color, num_workers], outputs=[gallery_processed, output_zip, processing_time])
511
  gallery_processed.select(update_compare, outputs=[image_original, image_processed, original_ratio, processed_ratio])
512
 
513
+ gr.Markdown("### ⚠️ Note:")
514
+ gr.Markdown("Processing may take a while due to the free CPU resources on Hugging Face Spaces. Please be patient!")
515
+
516
  iface.launch(share=True)