Spaces:
Sleeping
Sleeping
| from image_processor import process_zip_and_generate_images | |
| import gradio as gr | |
| import os | |
| def create_main_app(): | |
| with (gr.Blocks() as demo): | |
| gr.Markdown("# Bulk Creative Generation") | |
| gr.Markdown("Bulk Creative Generation is a tool where you can upload zip of upto 10 images which will create 10 different image for every single image present in the zip. Make sure the user prompt which you will write will be applicable to each image in the zip. Make sure you use this tool wisely.") | |
| gr.Markdown("## System Prompt:") | |
| gr.Markdown("""You are a top-tier performance digital marketer and creative strategist with 15+ years of expertise in affiliate marketing. | |
| Your objective is to analyze the provided winning template image and given ad image, deconstruct ad image concept, visual composition, and color scheme, and generate a fresh, conversion-focused ad visual in the given template image tailored for the {category} niche. | |
| The new design should convey a {sentiment} sentiment and incorporate the user instruction: {user_prompt}. | |
| Create a visually compelling ad optimized for {platform} Ads in the same template that is scroll-stopping, pattern-interrupting, and designed to drive high CTR and CR. Utilize striking color combinations, dynamic contrast levels, and strategic layout compositions to command attention while aligning with the target audience avatar and reinforcing the brand’s messaging.""") | |
| with gr.Column(): | |
| template_file = gr.File(label="Upload Template Image", file_types=[".png", ".jpg", ".jpeg"]) | |
| zip_file = gr.File(label="Upload Reference Image", file_types=[".png", ".jpg", ".jpeg"]) | |
| category = gr.Textbox(label="Category") | |
| with gr.Row(): | |
| size = gr.Dropdown(choices=["auto", "1024x1024", "1536x1024", "1024x1536"], label="Image Size") | |
| quality = gr.Dropdown(choices=["auto", "low", "medium"], label="Quality") | |
| sentiment = gr.Dropdown(choices=["same as original", "positive", "negative"]) | |
| user_prompt = gr.Textbox(label="User Prompt", lines=4) | |
| submit_btn = gr.Button("Generate") | |
| gallery = gr.Gallery(label="Generated Images") | |
| submit_btn.click( | |
| process_zip_and_generate_images, | |
| inputs=[zip_file, template_file, category, size, quality, user_prompt, sentiment], | |
| outputs=[gallery] | |
| ) | |
| return demo | |
| ACCESS_TOKEN = os.getenv("ACCESS_TOKEN") | |
| def check_token(user_token): | |
| if user_token == ACCESS_TOKEN: | |
| return gr.update(visible=True), gr.update(visible=False), "" | |
| return gr.update(visible=False), gr.update(visible=True), "❌ Invalid token." | |
| with gr.Blocks() as auth_wrapper: | |
| gr.Markdown("## 🔐 Access Required") | |
| token_input = gr.Textbox(label="Enter Access Token", type="password") | |
| unlock_btn = gr.Button("Unlock App") | |
| error_msg = gr.Markdown(visible=False) | |
| main_app = gr.Column(visible=False) | |
| with main_app: | |
| app = create_main_app() | |
| unlock_btn.click( | |
| fn=check_token, | |
| inputs=[token_input], | |
| outputs=[main_app, error_msg, error_msg] | |
| ) | |
| auth_wrapper.launch(debug=True) |