Noo88ear commited on
Commit
b0b7bfe
Β·
verified Β·
1 Parent(s): 570fcfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +317 -185
app.py CHANGED
@@ -1,5 +1,10 @@
1
  """
2
- Marketing Image Generator with AI Review
 
 
 
 
 
3
  """
4
 
5
  import gradio as gr
@@ -11,240 +16,367 @@ import io
11
  import os
12
  import hashlib
13
  import logging
14
- import google.generativeai as genai
15
- from google import genai as genai_sdk
16
 
17
  # Configure logging
18
  logging.basicConfig(level=logging.INFO)
19
  logger = logging.getLogger(__name__)
20
 
21
- # Configuration
 
22
  GOOGLE_SERVICE_ACCOUNT_JSON = os.getenv("GOOGLE_SERVICE_ACCOUNT_JSON", "")
23
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY", "")
24
 
25
- # Initialize Google AI
26
- google_auth_configured = False
27
-
28
- if GOOGLE_SERVICE_ACCOUNT_JSON:
29
- try:
 
30
  credentials_dict = json.loads(GOOGLE_SERVICE_ACCOUNT_JSON)
31
  from google.oauth2 import service_account
32
  credentials = service_account.Credentials.from_service_account_info(credentials_dict)
33
  genai.configure(credentials=credentials)
34
  google_auth_configured = True
35
  logger.info("βœ… Google Cloud configured")
36
- except Exception as e:
37
- logger.error(f"Google Cloud setup failed: {e}")
38
-
39
- if not google_auth_configured and GOOGLE_API_KEY:
40
- try:
41
  genai.configure(api_key=GOOGLE_API_KEY)
42
  google_auth_configured = True
43
- logger.info("βœ… Google API key configured")
44
- except Exception as e:
45
- logger.error(f"Google API setup failed: {e}")
46
-
47
- def create_placeholder_image(prompt, style, aspect_ratio):
48
- """Create a clean placeholder image"""
49
- # Set dimensions
50
- if aspect_ratio == "Square (1:1)":
51
- width, height = 512, 512
52
- elif aspect_ratio == "Portrait (3:4)":
53
- width, height = 512, 683
54
- else: # Landscape (16:9)
55
- width, height = 683, 384
56
-
57
- # Generate color from prompt
58
- prompt_hash = int(hashlib.md5(prompt.encode()).hexdigest()[:8], 16)
59
-
60
- # Clean color palette
61
- colors = {
62
- "Professional": "#3B82F6", # Blue
63
- "Creative": "#8B5CF6", # Purple
64
- "Minimalist": "#6B7280", # Gray
65
- "Corporate": "#1E40AF", # Dark Blue
66
- "Modern": "#059669" # Green
67
- }
68
-
69
- base_color = colors.get(style, "#3B82F6")
70
-
71
- # Convert hex to RGB
72
- hex_color = base_color.lstrip('#')
73
- rgb = tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
74
-
75
- # Create image
76
- img = Image.new('RGB', (width, height), rgb)
77
- draw = ImageDraw.Draw(img)
78
-
79
- # Add text
80
- try:
81
- font = ImageFont.load_default()
82
-
83
- # Main text
84
- text = "Marketing Image"
85
- bbox = draw.textbbox((0, 0), text, font=font)
86
- text_width = bbox[2] - bbox[0]
87
- text_height = bbox[3] - bbox[1]
88
- x = (width - text_width) // 2
89
- y = (height - text_height) // 2 - 20
90
-
91
- draw.text((x, y), text, fill="white", font=font)
92
-
93
- # Style text
94
- style_text = f"Style: {style}"
95
- bbox2 = draw.textbbox((0, 0), style_text, font=font)
96
- text_width2 = bbox2[2] - bbox2[0]
97
- x2 = (width - text_width2) // 2
98
- draw.text((x2, y + 30), style_text, fill="white", font=font)
99
-
100
- except:
101
- pass
102
-
103
- return img
104
-
105
- def generate_with_google_imagen(prompt, style):
106
- """Try to generate with real Google Imagen"""
107
- if not google_auth_configured:
108
- return None
109
-
110
- try:
111
- # Enhance prompt
112
- enhanced_prompt = f"{prompt}, {style.lower()} style, high quality, professional marketing image, 4K"
113
-
114
- if GOOGLE_SERVICE_ACCOUNT_JSON:
115
- client = genai_sdk.Client()
116
- else:
117
- client = genai_sdk.Client(api_key=GOOGLE_API_KEY)
118
-
119
- result = client.models.generate_images(
120
- model="imagen-3.0-generate-002",
121
- prompt=enhanced_prompt,
122
- config={
123
- "number_of_images": 1,
124
- "output_mime_type": "image/png"
125
- }
126
- )
127
-
128
- if result and hasattr(result, 'generated_images') and len(result.generated_images) > 0:
129
- generated_image = result.generated_images[0]
130
- if hasattr(generated_image, 'image') and hasattr(generated_image.image, 'image_bytes'):
131
- image_bytes = generated_image.image.image_bytes
132
- return Image.open(io.BytesIO(image_bytes))
133
 
134
- except Exception as e:
135
- logger.warning(f"Google Imagen failed: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
- return None
138
-
139
- def review_with_gemini(image, prompt):
140
- """Review image with Gemini Vision"""
141
- if not google_auth_configured:
142
- return "Demo mode - no AI review available"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
- try:
145
- model = genai.GenerativeModel('gemini-2.0-flash-exp')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
- review_prompt = f"""
148
- Review this marketing image generated from: "{prompt}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
 
150
- Rate it 1-10 and provide brief feedback on:
151
- - Visual quality and clarity
152
- - Marketing effectiveness
153
- - How well it matches the prompt
154
 
155
- Keep response under 100 words.
156
- """
 
 
 
 
 
 
 
 
157
 
158
- response = model.generate_content([review_prompt, image])
159
- return response.text[:200]
 
 
 
 
 
160
 
161
- except Exception as e:
162
- logger.warning(f"Gemini review failed: {e}")
163
- return "AI review unavailable"
 
 
 
164
 
165
- def generate_image(prompt, style, aspect_ratio):
166
- """Main generation function"""
167
- if not prompt.strip():
168
- return None, "Please enter a description"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
- # Try real AI generation first
171
- if google_auth_configured:
172
- real_image = generate_with_google_imagen(prompt, style)
173
- if real_image:
174
- review = review_with_gemini(real_image, prompt)
175
- return real_image, f"βœ… Generated with Google Imagen\n\nAI Review: {review}"
176
 
177
- # Fallback to placeholder
178
- placeholder = create_placeholder_image(prompt, style, aspect_ratio)
179
 
180
- # Simple quality estimate
181
- word_count = len(prompt.split())
182
- quality = "Good" if word_count > 10 else "Basic"
183
 
184
- feedback = f"⚠️ Demo mode active\n\nPrompt quality: {quality}\nStyle: {style}\n\nTo use real AI generation, configure Google Cloud credentials."
 
 
 
 
 
 
 
 
 
 
185
 
186
- return placeholder, feedback
 
 
 
 
 
 
 
187
 
188
- # Create clean Gradio interface
189
- with gr.Blocks(title="Marketing Image Generator", theme=gr.themes.Default()) as demo:
 
 
 
190
 
191
- gr.Markdown("""
192
- # 🎨 Marketing Image Generator
193
- Create professional marketing images with AI-powered review
194
- """)
 
 
 
 
195
 
196
  # Status
197
- if google_auth_configured:
198
- gr.Markdown("βœ… **Status**: Google AI Connected - Real image generation active")
199
- else:
200
- gr.Markdown("⚠️ **Status**: Demo Mode - Configure Google Cloud for real AI generation")
201
 
202
  with gr.Row():
203
- with gr.Column():
204
- # Inputs
205
  prompt = gr.Textbox(
206
- label="Describe your marketing image",
207
- placeholder="A professional team collaborating in a modern office space...",
208
- lines=3
209
  )
210
 
211
- with gr.Row():
212
- style = gr.Dropdown(
213
- ["Professional", "Creative", "Minimalist", "Corporate", "Modern"],
214
- value="Professional",
215
- label="Style"
216
- )
217
-
218
- aspect_ratio = gr.Dropdown(
219
- ["Landscape (16:9)", "Square (1:1)", "Portrait (3:4)"],
220
- value="Landscape (16:9)",
221
- label="Aspect Ratio"
222
- )
223
 
224
- generate_btn = gr.Button("Generate Image", variant="primary", size="lg")
225
 
226
- with gr.Column():
227
- # Outputs
228
- image_output = gr.Image(label="Generated Image", height=400)
229
- feedback_output = gr.Textbox(label="AI Review", lines=4)
 
 
230
 
231
  # Examples
232
- gr.Markdown("### Example Prompts")
233
- examples = gr.Examples(
234
  examples=[
235
- ["A diverse team of professionals in a bright modern office", "Professional", "Landscape (16:9)"],
236
- ["A sleek product photo with clean white background", "Minimalist", "Square (1:1)"],
237
- ["A friendly customer service representative with headset", "Corporate", "Portrait (3:4)"],
238
- ["An inspiring workspace with laptop and coffee", "Modern", "Landscape (16:9)"]
239
  ],
240
  inputs=[prompt, style, aspect_ratio]
241
  )
242
 
243
- # Connect function
244
  generate_btn.click(
245
- fn=generate_image,
246
  inputs=[prompt, style, aspect_ratio],
247
- outputs=[image_output, feedback_output]
 
248
  )
249
 
250
  if __name__ == "__main__":
 
1
  """
2
+ Marketing Image Generator - Agent Workflow Test Version
3
+
4
+ This version clearly shows the Agent1 -> Agent2 workflow:
5
+ - Agent1: Image Generator (calls Google Imagen)
6
+ - Agent2: Image Reviewer (calls Google Gemini Vision)
7
+ - Clear logging of each step
8
  """
9
 
10
  import gradio as gr
 
16
  import os
17
  import hashlib
18
  import logging
 
 
19
 
20
  # Configure logging
21
  logging.basicConfig(level=logging.INFO)
22
  logger = logging.getLogger(__name__)
23
 
24
+ # Google AI setup
25
+ google_auth_configured = False
26
  GOOGLE_SERVICE_ACCOUNT_JSON = os.getenv("GOOGLE_SERVICE_ACCOUNT_JSON", "")
27
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY", "")
28
 
29
+ # Try to configure Google AI
30
+ try:
31
+ import google.generativeai as genai
32
+ from google import genai as genai_sdk
33
+
34
+ if GOOGLE_SERVICE_ACCOUNT_JSON:
35
  credentials_dict = json.loads(GOOGLE_SERVICE_ACCOUNT_JSON)
36
  from google.oauth2 import service_account
37
  credentials = service_account.Credentials.from_service_account_info(credentials_dict)
38
  genai.configure(credentials=credentials)
39
  google_auth_configured = True
40
  logger.info("βœ… Google Cloud configured")
41
+ elif GOOGLE_API_KEY:
 
 
 
 
42
  genai.configure(api_key=GOOGLE_API_KEY)
43
  google_auth_configured = True
44
+ logger.info("βœ… Google API configured")
45
+ except Exception as e:
46
+ logger.error(f"Google setup failed: {e}")
47
+ genai = None
48
+
49
+ # ====== AGENT 1: IMAGE GENERATOR ======
50
+
51
+ class ImageGeneratorAgent:
52
+ """Agent 1: Responsible for generating images using Google Imagen"""
53
+
54
+ def __init__(self):
55
+ self.name = "ImageGeneratorAgent"
56
+ self.status = "Ready"
57
+
58
+ def enhance_prompt(self, prompt, style):
59
+ """Enhance user prompt for better results"""
60
+ logger.info(f"πŸ€– Agent1: Enhancing prompt for {style} style")
61
+
62
+ style_enhancers = {
63
+ "Professional": "professional photography, corporate setting, high quality, clean composition, marketing ready",
64
+ "Creative": "creative composition, artistic flair, innovative design, vibrant colors, eye-catching",
65
+ "Minimalist": "clean minimal design, simple composition, white space, elegant, professional",
66
+ "Corporate": "business professional, corporate branding, trustworthy, authoritative, polished",
67
+ "Modern": "contemporary design, sleek, cutting-edge, stylish, trendy"
68
+ }
69
+
70
+ enhancer = style_enhancers.get(style, "high quality, professional")
71
+ enhanced = f"{prompt}, {enhancer}, 4K resolution, sharp focus, marketing quality"
72
+
73
+ logger.info(f"πŸ€– Agent1: Enhanced prompt: {enhanced[:100]}...")
74
+ return enhanced
75
+
76
+ def generate_image(self, prompt, style, aspect_ratio):
77
+ """Generate image using Google Imagen"""
78
+ logger.info(f"πŸ€– Agent1: Starting image generation")
79
+ logger.info(f"πŸ€– Agent1: Original prompt: {prompt}")
80
+ logger.info(f"πŸ€– Agent1: Style: {style}, Format: {aspect_ratio}")
81
+
82
+ # Step 1: Enhance prompt
83
+ enhanced_prompt = self.enhance_prompt(prompt, style)
84
+
85
+ # Step 2: Try Google Imagen
86
+ if google_auth_configured and genai:
87
+ try:
88
+ logger.info(f"πŸ€– Agent1: Calling Google Imagen API...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
+ if GOOGLE_SERVICE_ACCOUNT_JSON:
91
+ client = genai_sdk.Client()
92
+ else:
93
+ client = genai_sdk.Client(api_key=GOOGLE_API_KEY)
94
+
95
+ result = client.models.generate_images(
96
+ model="imagen-3.0-generate-002",
97
+ prompt=enhanced_prompt,
98
+ config={
99
+ "number_of_images": 1,
100
+ "output_mime_type": "image/png"
101
+ }
102
+ )
103
+
104
+ if result and hasattr(result, 'generated_images') and result.generated_images:
105
+ img_data = result.generated_images[0]
106
+ if hasattr(img_data, 'image') and hasattr(img_data.image, 'image_bytes'):
107
+ image = Image.open(io.BytesIO(img_data.image.image_bytes))
108
+ logger.info(f"βœ… Agent1: Successfully generated real image with Google Imagen!")
109
+ return {
110
+ "success": True,
111
+ "image": image,
112
+ "method": "Google Imagen",
113
+ "enhanced_prompt": enhanced_prompt,
114
+ "agent": "ImageGeneratorAgent"
115
+ }
116
+
117
+ logger.warning(f"⚠️ Agent1: Google Imagen returned no images")
118
+
119
+ except Exception as e:
120
+ logger.error(f"❌ Agent1: Google Imagen failed: {e}")
121
+
122
+ # Step 3: Fallback to demo image
123
+ logger.info(f"πŸ€– Agent1: Creating demo image (fallback)")
124
+ demo_image = self.create_demo_image(prompt, style, aspect_ratio)
125
+
126
+ return {
127
+ "success": True,
128
+ "image": demo_image,
129
+ "method": "Demo Mode",
130
+ "enhanced_prompt": enhanced_prompt,
131
+ "agent": "ImageGeneratorAgent"
132
+ }
133
 
134
+ def create_demo_image(self, prompt, style, aspect_ratio):
135
+ """Create demo image when API isn't available"""
136
+ # Set dimensions
137
+ if "Square" in aspect_ratio:
138
+ width, height = 400, 400
139
+ elif "Portrait" in aspect_ratio:
140
+ width, height = 400, 500
141
+ else:
142
+ width, height = 500, 300
143
+
144
+ # Style colors
145
+ colors = {
146
+ "Professional": (59, 130, 246),
147
+ "Creative": (139, 92, 246),
148
+ "Minimalist": (107, 114, 128),
149
+ "Corporate": (30, 64, 175),
150
+ "Modern": (5, 150, 105)
151
+ }
152
+
153
+ color = colors.get(style, (59, 130, 246))
154
+ img = Image.new('RGB', (width, height), color)
155
+ draw = ImageDraw.Draw(img)
156
 
157
+ try:
158
+ font = ImageFont.load_default()
159
+
160
+ # Add text overlay
161
+ title = "Marketing Image"
162
+ bbox = draw.textbbox((0, 0), title, font=font)
163
+ text_width = bbox[2] - bbox[0]
164
+ x = (width - text_width) // 2
165
+ y = height // 2 - 30
166
+ draw.text((x, y), title, fill="white", font=font)
167
+
168
+ style_text = f"{style} Style"
169
+ bbox2 = draw.textbbox((0, 0), style_text, font=font)
170
+ text_width2 = bbox2[2] - bbox2[0]
171
+ x2 = (width - text_width2) // 2
172
+ draw.text((x2, y + 25), style_text, fill="white", font=font)
173
+
174
+ except:
175
+ pass
176
+
177
+ return img
178
+
179
+ # ====== AGENT 2: IMAGE REVIEWER ======
180
+
181
+ class ImageReviewerAgent:
182
+ """Agent 2: Responsible for reviewing images using Google Gemini Vision"""
183
+
184
+ def __init__(self):
185
+ self.name = "ImageReviewerAgent"
186
+ self.status = "Ready"
187
+
188
+ def review_image(self, image, original_prompt, enhanced_prompt, generation_method):
189
+ """Review generated image for quality and marketing effectiveness"""
190
+ logger.info(f"πŸ” Agent2: Starting image review")
191
+ logger.info(f"πŸ” Agent2: Reviewing image generated by: {generation_method}")
192
+ logger.info(f"πŸ” Agent2: Original prompt: {original_prompt}")
193
 
194
+ if google_auth_configured and genai and generation_method == "Google Imagen":
195
+ try:
196
+ logger.info(f"πŸ” Agent2: Calling Google Gemini Vision for AI review...")
197
+
198
+ model = genai.GenerativeModel('gemini-2.0-flash-exp')
199
+
200
+ review_prompt = f"""You are an expert marketing image reviewer. Analyze this image that was generated from the prompt: "{original_prompt}"
201
+
202
+ Rate the image on a scale of 1-10 and provide specific feedback on:
203
+ 1. Technical Quality (clarity, composition, lighting)
204
+ 2. Marketing Effectiveness (professional appeal, brand suitability)
205
+ 3. Prompt Matching (how well it matches the original request)
206
+
207
+ Provide your response in this format:
208
+ SCORE: X/10
209
+ QUALITY: [brief assessment]
210
+ MARKETING: [marketing effectiveness]
211
+ MATCHING: [how well it matches prompt]
212
+ RECOMMENDATIONS: [specific improvements]
213
+
214
+ Keep total response under 200 words."""
215
+
216
+ response = model.generate_content([review_prompt, image])
217
+ review_text = response.text
218
+
219
+ logger.info(f"βœ… Agent2: AI review completed successfully")
220
+ logger.info(f"πŸ” Agent2: Review preview: {review_text[:100]}...")
221
+
222
+ return {
223
+ "success": True,
224
+ "review": review_text,
225
+ "method": "Gemini Vision AI",
226
+ "agent": "ImageReviewerAgent"
227
+ }
228
+
229
+ except Exception as e:
230
+ logger.error(f"❌ Agent2: Gemini Vision review failed: {e}")
231
 
232
+ # Fallback review for demo mode
233
+ logger.info(f"πŸ” Agent2: Performing basic review (fallback)")
 
 
234
 
235
+ word_count = len(original_prompt.split())
236
+ if word_count > 15:
237
+ quality = "Excellent"
238
+ score = "8/10"
239
+ elif word_count > 8:
240
+ quality = "Good"
241
+ score = "7/10"
242
+ else:
243
+ quality = "Basic"
244
+ score = "6/10"
245
 
246
+ basic_review = f"""SCORE: {score}
247
+ QUALITY: {quality} prompt with {word_count} descriptive words
248
+ MARKETING: Suitable for {generation_method.lower()} marketing use
249
+ MATCHING: Generated image reflects the requested style and content
250
+ RECOMMENDATIONS: Add more specific details for enhanced results
251
+
252
+ Note: This is a basic review. Connect Google Cloud for full AI-powered analysis."""
253
 
254
+ return {
255
+ "success": True,
256
+ "review": basic_review,
257
+ "method": "Basic Analysis",
258
+ "agent": "ImageReviewerAgent"
259
+ }
260
 
261
+ # ====== ORCHESTRATOR: MANAGES AGENT WORKFLOW ======
262
+
263
+ def orchestrate_workflow(prompt, style, aspect_ratio):
264
+ """Main workflow orchestrator - manages Agent1 -> Agent2 pipeline"""
265
+ logger.info(f"🎭 ORCHESTRATOR: Starting agent workflow")
266
+ logger.info(f"🎭 ORCHESTRATOR: Input - Prompt: {prompt}, Style: {style}, Format: {aspect_ratio}")
267
+
268
+ if not prompt or not prompt.strip():
269
+ return None, "❌ ORCHESTRATOR: No prompt provided", "Workflow failed"
270
+
271
+ workflow_log = []
272
+
273
+ # Step 1: Initialize agents
274
+ logger.info(f"🎭 ORCHESTRATOR: Initializing agents...")
275
+ agent1 = ImageGeneratorAgent()
276
+ agent2 = ImageReviewerAgent()
277
+ workflow_log.append("βœ… Agents initialized")
278
+
279
+ # Step 2: Agent1 generates image
280
+ logger.info(f"🎭 ORCHESTRATOR: Calling Agent1 (ImageGenerator)...")
281
+ workflow_log.append("πŸ€– Agent1: Starting image generation...")
282
+
283
+ generation_result = agent1.generate_image(prompt, style, aspect_ratio)
284
 
285
+ if not generation_result["success"]:
286
+ logger.error(f"🎭 ORCHESTRATOR: Agent1 failed")
287
+ return None, "❌ Image generation failed", "Workflow failed"
 
 
 
288
 
289
+ workflow_log.append(f"βœ… Agent1: Generated image using {generation_result['method']}")
 
290
 
291
+ # Step 3: Agent2 reviews image
292
+ logger.info(f"🎭 ORCHESTRATOR: Calling Agent2 (ImageReviewer)...")
293
+ workflow_log.append("πŸ” Agent2: Starting image review...")
294
 
295
+ review_result = agent2.review_image(
296
+ generation_result["image"],
297
+ prompt,
298
+ generation_result["enhanced_prompt"],
299
+ generation_result["method"]
300
+ )
301
+
302
+ workflow_log.append(f"βœ… Agent2: Review completed using {review_result['method']}")
303
+
304
+ # Step 4: Compile final results
305
+ logger.info(f"🎭 ORCHESTRATOR: Workflow completed successfully")
306
 
307
+ final_review = f"""🎭 AGENT WORKFLOW COMPLETED
308
+
309
+ πŸ“‹ WORKFLOW LOG:
310
+ {chr(10).join(workflow_log)}
311
+
312
+ πŸ€– AGENT1 RESULT:
313
+ Generated using: {generation_result['method']}
314
+ Enhanced prompt: {generation_result['enhanced_prompt'][:100]}...
315
 
316
+ πŸ” AGENT2 REVIEW:
317
+ {review_result['review']}
318
+
319
+ 🎯 SYSTEM STATUS: {"βœ… Full AI Pipeline" if google_auth_configured else "⚠️ Demo Mode"}
320
+ """
321
 
322
+ return generation_result["image"], final_review, "βœ… Workflow Success"
323
+
324
+ # ====== GRADIO INTERFACE ======
325
+
326
+ with gr.Blocks(title="Marketing Image Generator - Agent Workflow") as demo:
327
+
328
+ gr.Markdown("# 🎨 Marketing Image Generator - Agent Workflow")
329
+ gr.Markdown("**Agent1** (ImageGenerator) β†’ **Agent2** (ImageReviewer) β†’ **Results**")
330
 
331
  # Status
332
+ status_msg = "βœ… Google AI Connected - Full Agent Pipeline" if google_auth_configured else "⚠️ Demo Mode - Simulated Agent Workflow"
333
+ gr.Markdown(f"**Status:** {status_msg}")
 
 
334
 
335
  with gr.Row():
336
+ with gr.Column(scale=1):
 
337
  prompt = gr.Textbox(
338
+ label="Marketing Image Description",
339
+ placeholder="A professional team meeting in a modern office...",
340
+ lines=2
341
  )
342
 
343
+ style = gr.Dropdown(
344
+ ["Professional", "Creative", "Minimalist", "Corporate", "Modern"],
345
+ value="Professional",
346
+ label="Style"
347
+ )
348
+
349
+ aspect_ratio = gr.Dropdown(
350
+ ["Landscape (16:9)", "Square (1:1)", "Portrait (3:4)"],
351
+ value="Landscape (16:9)",
352
+ label="Format"
353
+ )
 
354
 
355
+ generate_btn = gr.Button("πŸš€ Start Agent Workflow", variant="primary")
356
 
357
+ with gr.Column(scale=1):
358
+ image_output = gr.Image(label="Generated Image", height=300)
359
+ workflow_status = gr.Textbox(label="Workflow Status", lines=1, max_lines=1)
360
+
361
+ # Detailed workflow log
362
+ workflow_output = gr.Textbox(label="Agent Workflow Log", lines=8, max_lines=12)
363
 
364
  # Examples
365
+ gr.Examples(
 
366
  examples=[
367
+ ["Professional team collaboration in modern office", "Professional", "Landscape (16:9)"],
368
+ ["Clean product showcase on white background", "Minimalist", "Square (1:1)"],
369
+ ["Customer service representative with headset", "Corporate", "Portrait (3:4)"]
 
370
  ],
371
  inputs=[prompt, style, aspect_ratio]
372
  )
373
 
374
+ # Connect workflow
375
  generate_btn.click(
376
+ fn=orchestrate_workflow,
377
  inputs=[prompt, style, aspect_ratio],
378
+ outputs=[image_output, workflow_output, workflow_status],
379
+ show_progress=True
380
  )
381
 
382
  if __name__ == "__main__":