Switch to Gemini + update requirements
Browse files- .env +1 -0
- app.py +40 -1
- results/result_20250910134302.png +3 -0
- uploads/Elianna and Friend.jpg +3 -0
- uploads/upload_1757507906.png +3 -0
.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
GOOGLE_API_KEY=AIzaSyAhN_jl2FRSq8qBPNws87LJWEGY3UtS_6o
|
app.py
CHANGED
|
@@ -12,6 +12,16 @@ import google.generativeai as genai # Gemini SDK
|
|
| 12 |
import gradio as gr
|
| 13 |
import uvicorn
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# ---------------------------
|
| 16 |
# CONFIG
|
| 17 |
# ---------------------------
|
|
@@ -118,6 +128,35 @@ with gr.Blocks(css="footer {display:none !important}") as demo:
|
|
| 118 |
gr.Markdown("Upload your product photo, replace background, and auto-generate marketing captions + hashtags!")
|
| 119 |
|
| 120 |
# Image Editor Tab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
with gr.Tab("📸 Image Editor"):
|
| 122 |
with gr.Row():
|
| 123 |
input_img = gr.Image(type="pil", label="Upload Photo")
|
|
@@ -137,7 +176,7 @@ with gr.Blocks(css="footer {display:none !important}") as demo:
|
|
| 137 |
caption_box = gr.Textbox(label="Suggested Posts (multi-platform)", lines=12)
|
| 138 |
btn2.click(fn=generate_caption, inputs=[prompt], outputs=[caption_box])
|
| 139 |
|
| 140 |
-
|
| 141 |
# START SERVER
|
| 142 |
# ---------------------------
|
| 143 |
if __name__ == "__main__":
|
|
|
|
| 12 |
import gradio as gr
|
| 13 |
import uvicorn
|
| 14 |
|
| 15 |
+
from dotenv import load_dotenv
|
| 16 |
+
|
| 17 |
+
# Load environment variables from .env
|
| 18 |
+
load_dotenv()
|
| 19 |
+
|
| 20 |
+
# Confirm API key is loaded
|
| 21 |
+
print("Gemini API Key Loaded:", os.getenv("GOOGLE_API_KEY") is not None)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
# ---------------------------
|
| 26 |
# CONFIG
|
| 27 |
# ---------------------------
|
|
|
|
| 128 |
gr.Markdown("Upload your product photo, replace background, and auto-generate marketing captions + hashtags!")
|
| 129 |
|
| 130 |
# Image Editor Tab
|
| 131 |
+
|
| 132 |
+
# Image Editor Tab
|
| 133 |
+
with gr.Tab("📸 Image Editor"):
|
| 134 |
+
with gr.Row():
|
| 135 |
+
input_img = gr.Image(type="pil", label="Upload Photo")
|
| 136 |
+
|
| 137 |
+
with gr.Column():
|
| 138 |
+
bg_choices = gr.Dropdown(
|
| 139 |
+
choices=os.listdir(BG_DIR),
|
| 140 |
+
value=os.listdir(BG_DIR)[0] if os.listdir(BG_DIR) else None,
|
| 141 |
+
label="Choose Background"
|
| 142 |
+
)
|
| 143 |
+
bg_preview = gr.Image(
|
| 144 |
+
label="Background Preview",
|
| 145 |
+
type="filepath"
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
# Update preview whenever background changes
|
| 149 |
+
def update_preview(bg_choice):
|
| 150 |
+
return os.path.join(BG_DIR, bg_choice) if bg_choice else None
|
| 151 |
+
|
| 152 |
+
bg_choices.change(fn=update_preview, inputs=bg_choices, outputs=bg_preview)
|
| 153 |
+
|
| 154 |
+
btn = gr.Button("✨ Generate New Photo")
|
| 155 |
+
output_imgs = gr.Gallery(label="Generated Image", elem_id="gallery", columns=1, rows=1)
|
| 156 |
+
btn.click(fn=process_image, inputs=[input_img, bg_choices], outputs=output_imgs)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
'''
|
| 160 |
with gr.Tab("📸 Image Editor"):
|
| 161 |
with gr.Row():
|
| 162 |
input_img = gr.Image(type="pil", label="Upload Photo")
|
|
|
|
| 176 |
caption_box = gr.Textbox(label="Suggested Posts (multi-platform)", lines=12)
|
| 177 |
btn2.click(fn=generate_caption, inputs=[prompt], outputs=[caption_box])
|
| 178 |
|
| 179 |
+
'''
|
| 180 |
# START SERVER
|
| 181 |
# ---------------------------
|
| 182 |
if __name__ == "__main__":
|
results/result_20250910134302.png
ADDED
|
Git LFS Details
|
uploads/Elianna and Friend.jpg
ADDED
|
Git LFS Details
|
uploads/upload_1757507906.png
ADDED
|
Git LFS Details
|