gaur3009 commited on
Commit
51df96d
·
verified ·
1 Parent(s): fd9f176

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
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
- # Gallery Images with captions
121
- gallery_images = [
122
- ("https://gaur3009-phone-c.hf.space/gradio_api/file=/tmp/gradio/387f5407e32dd2e2d9e7017977f5ee98e4f40dcb8b1d2a9ef23612255a675163/image.webp", "Red Color, iPhone 14, Naruto Anime Theme"),
123
- ("https://gaur3009-phone-c.hf.space/gradio_api/file=/tmp/gradio/3037d9cae7a86b29be5969cf3a361ae847915b54d97d6d5dffb6e019a2b9ddc9/image.webp", "Red Color, iPhone 14, Darth Vader Theme"),
124
- ("https://gaur3009-phone-c.hf.space/gradio_api/file=/tmp/gradio/1958c8d60219357edbb2e1f69331152f1cd1109407b274c4511a810650dd574b/image.webp", "Black, iPhone 15, Thomas Shelby (Peaky Blinders) Theme"),
125
- ("https://gaur3009-phone-c.hf.space/gradio_api/file=/tmp/gradio/183392add00a7fa3d53653f856bc88d4113bd74c0d37c43de7a9af414e9c1d84/image.webp", "Green color, iPhone, Green Goblin"),
126
- ("https://gaur3009-phone-c.hf.space/gradio_api/file=/tmp/gradio/b7b0b2415f15f810f71658616a885b97c0466d09f1d852684a868ab9b5d18e6c/image.webp", "White and Cream Color, iPhone 15, Iron-Man"),
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 img_url, caption in gallery_images:
142
- gallery_html += f"<div class='image-container'><img src='{img_url}' alt='Design'><div class='caption'>{caption}</div></div>"
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)