Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from PIL import Image
|
|
4 |
from io import BytesIO
|
5 |
from tqdm import tqdm
|
6 |
import time
|
|
|
7 |
|
8 |
repo = "artificialguybr/TshirtDesignRedmond-V2"
|
9 |
|
@@ -117,14 +118,18 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
117 |
</script>
|
118 |
"""
|
119 |
|
120 |
-
#
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
]
|
|
|
|
|
|
|
|
|
128 |
|
129 |
# Gradio interface
|
130 |
with gr.Blocks(css=custom_css) as interface:
|
@@ -138,8 +143,8 @@ with gr.Blocks(css=custom_css) as interface:
|
|
138 |
gr.Markdown("Welcome to the **AI Phone Cover Designer**! Use the 'Design' tab to start creating custom designs.")
|
139 |
gr.Markdown("### Gallery")
|
140 |
gallery_html = "<div class='carousel'>"
|
141 |
-
for
|
142 |
-
gallery_html += f"<div class='image-container'><img src='{
|
143 |
gallery_html += "</div>"
|
144 |
gr.HTML(gallery_html)
|
145 |
|
@@ -183,4 +188,4 @@ with gr.Blocks(css=custom_css) as interface:
|
|
183 |
""")
|
184 |
|
185 |
# Launch the app
|
186 |
-
interface.launch(debug=True)
|
|
|
4 |
from io import BytesIO
|
5 |
from tqdm import tqdm
|
6 |
import time
|
7 |
+
import os
|
8 |
|
9 |
repo = "artificialguybr/TshirtDesignRedmond-V2"
|
10 |
|
|
|
118 |
</script>
|
119 |
"""
|
120 |
|
121 |
+
# Function to load images dynamically from "New folder (4)"
|
122 |
+
def load_gallery_images():
|
123 |
+
folder_path = "New folder (4)"
|
124 |
+
images_with_captions = []
|
125 |
+
for filename in os.listdir(folder_path):
|
126 |
+
if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.webp')):
|
127 |
+
img_path = os.path.join(folder_path, filename)
|
128 |
+
caption = filename.rsplit('.', 1)[0] # Use filename (without extension) as caption
|
129 |
+
images_with_captions.append((img_path, caption))
|
130 |
+
return images_with_captions
|
131 |
+
|
132 |
+
gallery_images = load_gallery_images()
|
133 |
|
134 |
# Gradio interface
|
135 |
with gr.Blocks(css=custom_css) as interface:
|
|
|
143 |
gr.Markdown("Welcome to the **AI Phone Cover Designer**! Use the 'Design' tab to start creating custom designs.")
|
144 |
gr.Markdown("### Gallery")
|
145 |
gallery_html = "<div class='carousel'>"
|
146 |
+
for img_path, caption in gallery_images:
|
147 |
+
gallery_html += f"<div class='image-container'><img src='{img_path}' alt='Design'><div class='caption'>{caption}</div></div>"
|
148 |
gallery_html += "</div>"
|
149 |
gr.HTML(gallery_html)
|
150 |
|
|
|
188 |
""")
|
189 |
|
190 |
# Launch the app
|
191 |
+
interface.launch(debug=True)
|