muhammadsalmanalfaridzi
commited on
Commit
β’
0160002
1
Parent(s):
4c32a7b
Update app.py
Browse files
app.py
CHANGED
@@ -59,7 +59,7 @@ def remove_background_bria(input_path):
|
|
59 |
|
60 |
return output_image
|
61 |
|
62 |
-
#
|
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
|
429 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
|
431 |
# Fitur Text to Image
|
432 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|