Update app.py
Browse files
app.py
CHANGED
@@ -45,8 +45,9 @@ def infer(color_prompt, phone_type_prompt, design_prompt):
|
|
45 |
|
46 |
# Save the design
|
47 |
def save_design(image):
|
48 |
-
|
49 |
-
os.makedirs(
|
|
|
50 |
image.save(file_path)
|
51 |
return f"Design saved as {file_path}!"
|
52 |
|
@@ -119,13 +120,21 @@ with gr.Blocks(css=custom_css) as interface:
|
|
119 |
with gr.Tabs():
|
120 |
with gr.Tab("Home"):
|
121 |
gr.Markdown("Welcome to the **AI Phone Cover Designer**! Below are some of your saved designs.")
|
122 |
-
saved_images_gallery = gr.Gallery(label="Saved Designs")
|
123 |
|
124 |
-
#
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
126 |
return fetch_saved_designs()
|
127 |
|
128 |
-
|
|
|
|
|
|
|
|
|
129 |
|
130 |
with gr.Tab("Design"):
|
131 |
with gr.Row():
|
@@ -167,4 +176,4 @@ with gr.Blocks(css=custom_css) as interface:
|
|
167 |
""")
|
168 |
|
169 |
# Launch the app
|
170 |
-
interface.launch(debug=True)
|
|
|
45 |
|
46 |
# Save the design
|
47 |
def save_design(image):
|
48 |
+
saved_designs_dir = "saved_designs"
|
49 |
+
os.makedirs(saved_designs_dir, exist_ok=True)
|
50 |
+
file_path = os.path.join(saved_designs_dir, f"design_{int(time.time())}.png")
|
51 |
image.save(file_path)
|
52 |
return f"Design saved as {file_path}!"
|
53 |
|
|
|
120 |
with gr.Tabs():
|
121 |
with gr.Tab("Home"):
|
122 |
gr.Markdown("Welcome to the **AI Phone Cover Designer**! Below are some of your saved designs.")
|
|
|
123 |
|
124 |
+
# Gallery to display saved designs
|
125 |
+
saved_images_gallery = gr.Gallery(label="Saved Designs").style(grid=[2], height="400px")
|
126 |
+
|
127 |
+
# Button to refresh gallery
|
128 |
+
refresh_button = gr.Button("Refresh Gallery")
|
129 |
+
|
130 |
+
def refresh_gallery():
|
131 |
return fetch_saved_designs()
|
132 |
|
133 |
+
refresh_button.click(
|
134 |
+
refresh_gallery,
|
135 |
+
inputs=[],
|
136 |
+
outputs=[saved_images_gallery]
|
137 |
+
)
|
138 |
|
139 |
with gr.Tab("Design"):
|
140 |
with gr.Row():
|
|
|
176 |
""")
|
177 |
|
178 |
# Launch the app
|
179 |
+
interface.launch(debug=True)
|