gaur3009 commited on
Commit
7daed69
·
verified ·
1 Parent(s): 63137d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -17
app.py CHANGED
@@ -118,29 +118,18 @@ document.addEventListener('DOMContentLoaded', function () {
118
  </script>
119
  """
120
  def load_gallery_images():
121
- folder_path = "New folder (4)"
122
- images_with_captions = []
123
  if not os.path.exists(folder_path):
124
- return 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.abspath(os.path.join(folder_path, filename))
128
- caption = filename.rsplit('.', 1)[0]
129
- images_with_captions.append((img_path, caption))
130
- return images_with_captions
131
 
132
  gallery_images = load_gallery_images()
133
 
134
- gallery_html = "<div class='carousel'>"
135
- for img_path, caption in gallery_images:
136
- gallery_html += (
137
- f"<div class='image-container'>"
138
- f"<img src='file://{img_path}' alt='Design'>"
139
- f"<div class='caption'>{caption}</div>"
140
- f"</div>"
141
- )
142
- gallery_html += "</div>"
143
-
144
  with gr.Blocks(css=custom_css) as interface:
145
  gr.HTML(custom_js)
146
  gr.Markdown("# **AI Phone Cover Designer**")
@@ -150,7 +139,10 @@ with gr.Blocks(css=custom_css) as interface:
150
  with gr.Tab("Home"):
151
  gr.Markdown("Welcome to the **AI Phone Cover Designer**! Use the 'Design' tab to start creating custom designs.")
152
  gr.Markdown("### Gallery")
153
- gr.HTML(gallery_html)
 
 
 
154
 
155
  with gr.Tab("Design"):
156
  with gr.Row():
 
118
  </script>
119
  """
120
  def load_gallery_images():
121
+ folder_path = "New folder (4)" # Ensure this path is correct
122
+ images = []
123
  if not os.path.exists(folder_path):
124
+ return images
125
  for filename in os.listdir(folder_path):
126
  if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.webp')):
127
  img_path = os.path.abspath(os.path.join(folder_path, filename))
128
+ images.append(img_path) # Append only the file paths
129
+ return images
 
130
 
131
  gallery_images = load_gallery_images()
132
 
 
 
 
 
 
 
 
 
 
 
133
  with gr.Blocks(css=custom_css) as interface:
134
  gr.HTML(custom_js)
135
  gr.Markdown("# **AI Phone Cover Designer**")
 
139
  with gr.Tab("Home"):
140
  gr.Markdown("Welcome to the **AI Phone Cover Designer**! Use the 'Design' tab to start creating custom designs.")
141
  gr.Markdown("### Gallery")
142
+ if gallery_images:
143
+ gr.Gallery(value=gallery_images, label="Design Gallery").style(grid=[2], height="auto")
144
+ else:
145
+ gr.Markdown("No images found in the gallery folder.")
146
 
147
  with gr.Tab("Design"):
148
  with gr.Row():