Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,15 @@
|
|
1 |
"""
|
2 |
-
Marketing Image Generator
|
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
|
11 |
import json
|
12 |
-
import
|
13 |
-
import
|
14 |
from PIL import Image, ImageDraw, ImageFont
|
15 |
import io
|
16 |
-
import os
|
17 |
import hashlib
|
18 |
-
import logging
|
19 |
|
20 |
# Configure logging
|
21 |
logging.basicConfig(level=logging.INFO)
|
@@ -44,340 +38,180 @@ try:
|
|
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 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
else:
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
if not prompt or not prompt.strip():
|
269 |
-
return None, "
|
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 |
-
|
284 |
|
285 |
-
|
286 |
-
|
287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
|
289 |
-
|
290 |
-
|
291 |
-
|
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 |
-
|
|
|
|
|
|
|
303 |
|
304 |
-
|
305 |
-
logger.info(f"π ORCHESTRATOR: Workflow completed successfully")
|
306 |
|
307 |
-
|
308 |
|
309 |
-
|
310 |
-
|
311 |
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
label="Marketing Image Description",
|
339 |
-
placeholder="A professional team meeting in a modern office...",
|
340 |
-
lines=
|
341 |
-
)
|
342 |
-
|
343 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
)
|
373 |
|
374 |
-
|
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__ ==
|
383 |
-
|
|
|
1 |
"""
|
2 |
+
Marketing Image Generator with AI Review
|
3 |
+
Clean, simple Gradio interface
|
|
|
|
|
|
|
|
|
4 |
"""
|
5 |
|
6 |
import gradio as gr
|
7 |
import json
|
8 |
+
import os
|
9 |
+
import logging
|
10 |
from PIL import Image, ImageDraw, ImageFont
|
11 |
import io
|
|
|
12 |
import hashlib
|
|
|
13 |
|
14 |
# Configure logging
|
15 |
logging.basicConfig(level=logging.INFO)
|
|
|
38 |
logger.info("β
Google API configured")
|
39 |
except Exception as e:
|
40 |
logger.error(f"Google setup failed: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
def create_demo_image(prompt, style, width=512, height=512):
|
43 |
+
"""Create demo image"""
|
44 |
+
colors = {
|
45 |
+
"Professional": (59, 130, 246),
|
46 |
+
"Creative": (139, 92, 246),
|
47 |
+
"Minimalist": (107, 114, 128),
|
48 |
+
"Corporate": (30, 64, 175),
|
49 |
+
"Modern": (5, 150, 105)
|
50 |
+
}
|
51 |
+
|
52 |
+
color = colors.get(style, (59, 130, 246))
|
53 |
+
img = Image.new('RGB', (width, height), color)
|
54 |
+
draw = ImageDraw.Draw(img)
|
55 |
+
|
56 |
+
try:
|
57 |
+
font = ImageFont.load_default()
|
58 |
+
title = "Marketing Image"
|
59 |
+
bbox = draw.textbbox((0, 0), title, font=font)
|
60 |
+
text_width = bbox[2] - bbox[0]
|
61 |
+
x = (width - text_width) // 2
|
62 |
+
y = height // 2 - 20
|
63 |
+
draw.text((x, y), title, fill="white", font=font)
|
64 |
+
|
65 |
+
style_text = f"{style} Style"
|
66 |
+
bbox2 = draw.textbbox((0, 0), style_text, font=font)
|
67 |
+
text_width2 = bbox2[2] - bbox2[0]
|
68 |
+
x2 = (width - text_width2) // 2
|
69 |
+
draw.text((x2, y + 30), style_text, fill="white", font=font)
|
70 |
+
except:
|
71 |
+
pass
|
72 |
+
|
73 |
+
return img
|
74 |
+
|
75 |
+
def generate_with_google_ai(prompt, style):
|
76 |
+
"""Generate with Google Imagen"""
|
77 |
+
if not google_auth_configured:
|
78 |
+
return None
|
79 |
+
|
80 |
+
try:
|
81 |
+
enhanced_prompt = f"{prompt}, {style.lower()} style, professional marketing image, high quality, 4K"
|
82 |
+
|
83 |
+
if GOOGLE_SERVICE_ACCOUNT_JSON:
|
84 |
+
client = genai_sdk.Client()
|
85 |
else:
|
86 |
+
client = genai_sdk.Client(api_key=GOOGLE_API_KEY)
|
87 |
+
|
88 |
+
result = client.models.generate_images(
|
89 |
+
model="imagen-3.0-generate-002",
|
90 |
+
prompt=enhanced_prompt,
|
91 |
+
config={"number_of_images": 1, "output_mime_type": "image/png"}
|
92 |
+
)
|
93 |
+
|
94 |
+
if result and hasattr(result, 'generated_images') and result.generated_images:
|
95 |
+
img_data = result.generated_images[0]
|
96 |
+
if hasattr(img_data, 'image') and hasattr(img_data.image, 'image_bytes'):
|
97 |
+
return Image.open(io.BytesIO(img_data.image.image_bytes))
|
98 |
+
except Exception as e:
|
99 |
+
logger.warning(f"Google Imagen failed: {e}")
|
100 |
+
|
101 |
+
return None
|
102 |
+
|
103 |
+
def review_with_ai(image, prompt):
|
104 |
+
"""Review with Gemini"""
|
105 |
+
if not google_auth_configured:
|
106 |
+
return "Demo mode - Add Google credentials for AI review"
|
107 |
+
|
108 |
+
try:
|
109 |
+
model = genai.GenerativeModel('gemini-2.0-flash-exp')
|
110 |
+
review_prompt = f"Review this marketing image from: '{prompt}'. Rate 1-10 and give brief feedback. Keep under 100 words."
|
111 |
+
response = model.generate_content([review_prompt, image])
|
112 |
+
return response.text[:200]
|
113 |
+
except Exception as e:
|
114 |
+
logger.warning(f"AI review failed: {e}")
|
115 |
+
return "AI review unavailable"
|
116 |
+
|
117 |
+
def generate_marketing_image(prompt, style):
|
118 |
+
"""Main function - Agent1 generates, Agent2 reviews"""
|
119 |
if not prompt or not prompt.strip():
|
120 |
+
return None, "Please enter a prompt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
+
logger.info(f"π€ Agent1: Generating image for '{prompt}' in {style} style")
|
123 |
|
124 |
+
# Agent1: Try Google Imagen
|
125 |
+
if google_auth_configured:
|
126 |
+
real_image = generate_with_google_ai(prompt, style)
|
127 |
+
if real_image:
|
128 |
+
logger.info("β
Agent1: Real image generated with Google Imagen")
|
129 |
+
logger.info("π Agent2: Starting AI review...")
|
130 |
+
review = review_with_ai(real_image, prompt)
|
131 |
+
logger.info("β
Agent2: Review completed")
|
132 |
+
return real_image, f"β
Google Imagen + AI Review\n\n{review}"
|
133 |
|
134 |
+
# Agent1: Fallback to demo
|
135 |
+
logger.info("π€ Agent1: Creating demo image (fallback)")
|
136 |
+
demo_image = create_demo_image(prompt, style)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
+
# Agent2: Basic review
|
139 |
+
logger.info("π Agent2: Basic review (fallback)")
|
140 |
+
word_count = len(prompt.split())
|
141 |
+
quality = "Good" if word_count > 10 else "Basic"
|
142 |
|
143 |
+
review = f"Demo Mode Review:\n\nPrompt Quality: {quality} ({word_count} words)\nStyle: {style}\nRecommendation: Add Google credentials for full AI generation and review."
|
|
|
144 |
|
145 |
+
return demo_image, review
|
146 |
|
147 |
+
# Interface configuration
|
148 |
+
title = "π¨ Marketing Image Generator with AI Review"
|
149 |
|
150 |
+
description = """
|
151 |
+
<p style='text-align: center'>
|
152 |
+
<b>Agent-Based Marketing Image Generation</b><br>
|
153 |
+
Agent1 creates images with Google Imagen3 β Agent2 reviews with Gemini Vision
|
154 |
+
</p>
|
|
|
|
|
|
|
155 |
"""
|
|
|
|
|
156 |
|
157 |
+
article = """
|
158 |
+
<p style='text-align: center'>
|
159 |
+
<b>How it Works:</b><br>
|
160 |
+
1. Agent1 (Generator) enhances your prompt and creates professional marketing images<br>
|
161 |
+
2. Agent2 (Reviewer) analyzes the image for quality and marketing effectiveness<br>
|
162 |
+
3. Get instant feedback and download high-quality results
|
163 |
+
</p>
|
164 |
+
"""
|
165 |
|
166 |
+
examples = [
|
167 |
+
["Professional team collaboration in modern office", "Professional"],
|
168 |
+
["Clean product showcase on white background", "Minimalist"],
|
169 |
+
["Customer service representative with headset", "Corporate"],
|
170 |
+
["Modern workspace with laptop and plants", "Modern"],
|
171 |
+
["Creative marketing team brainstorming session", "Creative"]
|
172 |
+
]
|
173 |
+
|
174 |
+
def main():
|
175 |
+
# Status message
|
176 |
+
if google_auth_configured:
|
177 |
+
status_msg = "β
Google AI Connected - Full Agent Pipeline Active"
|
178 |
+
else:
|
179 |
+
status_msg = "β οΈ Demo Mode - Add GOOGLE_SERVICE_ACCOUNT_JSON for full AI capabilities"
|
180 |
+
|
181 |
+
full_description = f"""
|
182 |
+
{description}
|
183 |
+
<p style='text-align: center; color: {"green" if google_auth_configured else "orange"}'>
|
184 |
+
<b>Status:</b> {status_msg}
|
185 |
+
</p>
|
186 |
+
"""
|
187 |
+
|
188 |
+
iface = gr.Interface(
|
189 |
+
fn=generate_marketing_image,
|
190 |
+
inputs=[
|
191 |
+
gr.Textbox(
|
192 |
label="Marketing Image Description",
|
193 |
+
placeholder="A professional team meeting in a modern office space...",
|
194 |
+
lines=3
|
195 |
+
),
|
196 |
+
gr.Dropdown(
|
197 |
+
choices=["Professional", "Creative", "Minimalist", "Corporate", "Modern"],
|
|
|
198 |
value="Professional",
|
199 |
label="Style"
|
200 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
],
|
202 |
+
outputs=[
|
203 |
+
gr.Image(label="Generated Marketing Image", height=400),
|
204 |
+
gr.Textbox(label="AI Agent Review", lines=5)
|
205 |
+
],
|
206 |
+
title=title,
|
207 |
+
description=full_description,
|
208 |
+
article=article,
|
209 |
+
examples=examples,
|
210 |
+
theme="soft",
|
211 |
+
allow_flagging="never"
|
212 |
)
|
213 |
|
214 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
|
216 |
+
if __name__ == '__main__':
|
217 |
+
main()
|