Switch to Gemini + update requirements
Browse files
app.py
CHANGED
|
@@ -209,16 +209,22 @@ async def generate_captions_api(prompt: str = Form(...)):
|
|
| 209 |
# ---------------------------
|
| 210 |
# GRADIO UI
|
| 211 |
# ---------------------------
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
| 213 |
gr.Markdown("# ✨ SnapLift – AI Social Media Booster")
|
| 214 |
gr.Markdown("Upload your product photo, replace background, and auto-generate marketing captions + hashtags!")
|
| 215 |
|
|
|
|
| 216 |
# Image Editor Tab
|
|
|
|
| 217 |
with gr.Tab("📸 Image Editor"):
|
| 218 |
with gr.Row():
|
| 219 |
-
|
|
|
|
|
|
|
| 220 |
|
| 221 |
-
with gr.Column():
|
| 222 |
bg_choices = gr.Dropdown(
|
| 223 |
choices=os.listdir(BG_DIR) or ["default.png"],
|
| 224 |
value=(os.listdir(BG_DIR)[0] if os.listdir(BG_DIR) else None),
|
|
@@ -240,34 +246,46 @@ with gr.Blocks(css="footer {display:none !important}") as demo:
|
|
| 240 |
|
| 241 |
bg_choices.change(fn=load_bg, inputs=bg_choices, outputs=bg_preview)
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
blur_background = gr.Checkbox(label="Blur Background", value=False)
|
| 254 |
-
|
| 255 |
-
#brand_color = gr.ColorPicker(label="Brand Colour")
|
| 256 |
-
|
| 257 |
-
btn = gr.Button("✨ Generate New Photo")
|
| 258 |
-
output_imgs = gr.Gallery(label="Generated Image", elem_id="gallery", columns=1, rows=1)
|
| 259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
btn.click(
|
| 261 |
fn=process_image,
|
| 262 |
inputs=[input_img, bg_choices, bg_upload, logo_upload, logo_transparency, logo_position, blur_background, blend_strength],
|
| 263 |
outputs=output_imgs
|
| 264 |
)
|
| 265 |
|
|
|
|
| 266 |
# Caption Generator Tab
|
|
|
|
| 267 |
with gr.Tab("✍️ Caption Generator"):
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
btn2.click(fn=generate_caption, inputs=[prompt], outputs=[caption_box])
|
| 272 |
|
| 273 |
# ---------------------------
|
|
|
|
| 209 |
# ---------------------------
|
| 210 |
# GRADIO UI
|
| 211 |
# ---------------------------
|
| 212 |
+
# ---------------------------
|
| 213 |
+
# GRADIO UI
|
| 214 |
+
# ---------------------------
|
| 215 |
+
with gr.Blocks(css="footer {display:none !important}; .gradio-container {max-width: 100% !important}") as demo:
|
| 216 |
gr.Markdown("# ✨ SnapLift – AI Social Media Booster")
|
| 217 |
gr.Markdown("Upload your product photo, replace background, and auto-generate marketing captions + hashtags!")
|
| 218 |
|
| 219 |
+
# ---------------------------
|
| 220 |
# Image Editor Tab
|
| 221 |
+
# ---------------------------
|
| 222 |
with gr.Tab("📸 Image Editor"):
|
| 223 |
with gr.Row():
|
| 224 |
+
# ---- Left Column: Inputs & Controls ----
|
| 225 |
+
with gr.Column(scale=1):
|
| 226 |
+
input_img = gr.Image(type="pil", label="Upload Main Photo")
|
| 227 |
|
|
|
|
| 228 |
bg_choices = gr.Dropdown(
|
| 229 |
choices=os.listdir(BG_DIR) or ["default.png"],
|
| 230 |
value=(os.listdir(BG_DIR)[0] if os.listdir(BG_DIR) else None),
|
|
|
|
| 246 |
|
| 247 |
bg_choices.change(fn=load_bg, inputs=bg_choices, outputs=bg_preview)
|
| 248 |
|
| 249 |
+
logo_upload = gr.Image(type="pil", label="Upload Logo (Optional)")
|
| 250 |
+
logo_transparency = gr.Slider(0, 100, value=70, label="Logo Transparency (%)")
|
| 251 |
+
logo_position = gr.Dropdown(
|
| 252 |
+
["Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right", "Center"],
|
| 253 |
+
value="Bottom-Right",
|
| 254 |
+
label="Logo Position"
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
blend_strength = gr.Slider(0, 1, value=0.5, step=0.1, label="Blending Strength (Realism)")
|
| 258 |
+
blur_background = gr.Checkbox(label="Blur Background", value=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
|
| 260 |
+
btn = gr.Button("✨ Generate New Photo")
|
| 261 |
+
|
| 262 |
+
# ---- Right Column: Output ----
|
| 263 |
+
with gr.Column(scale=1):
|
| 264 |
+
output_imgs = gr.Gallery(
|
| 265 |
+
label="Generated Image",
|
| 266 |
+
elem_id="gallery",
|
| 267 |
+
columns=1,
|
| 268 |
+
rows=1
|
| 269 |
+
)
|
| 270 |
+
|
| 271 |
+
# Action binding
|
| 272 |
btn.click(
|
| 273 |
fn=process_image,
|
| 274 |
inputs=[input_img, bg_choices, bg_upload, logo_upload, logo_transparency, logo_position, blur_background, blend_strength],
|
| 275 |
outputs=output_imgs
|
| 276 |
)
|
| 277 |
|
| 278 |
+
# ---------------------------
|
| 279 |
# Caption Generator Tab
|
| 280 |
+
# ---------------------------
|
| 281 |
with gr.Tab("✍️ Caption Generator"):
|
| 282 |
+
with gr.Row():
|
| 283 |
+
with gr.Column(scale=1):
|
| 284 |
+
prompt = gr.Textbox(label="Enter product/promotion text", value="Promote my skincare product")
|
| 285 |
+
btn2 = gr.Button("💡 Suggest Captions + Hashtags")
|
| 286 |
+
with gr.Column(scale=1):
|
| 287 |
+
caption_box = gr.Textbox(label="Suggested Posts (multi-platform)", lines=12)
|
| 288 |
+
|
| 289 |
btn2.click(fn=generate_caption, inputs=[prompt], outputs=[caption_box])
|
| 290 |
|
| 291 |
# ---------------------------
|