Senasu commited on
Commit
b94e2db
·
verified ·
1 Parent(s): 2f9742d

Updated app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -66,9 +66,13 @@ if file is not None:
66
  for i, idx in enumerate(indices[0]):
67
  product_path = filenames[idx]
68
  product_path = product_path.replace('\\', '/')
69
- st.write(product_path)
70
- product_image = Image.open(product_path)
71
-
72
- # Assign columns dynamically
73
- with cols[i % 3]:
74
- st.image(product_image, caption=f"Product {i + 1}")
 
 
 
 
 
66
  for i, idx in enumerate(indices[0]):
67
  product_path = filenames[idx]
68
  product_path = product_path.replace('\\', '/')
69
+
70
+ # Check if the image exists before displaying
71
+ if os.path.exists(product_path):
72
+ product_image = Image.open(product_path)
73
+ # Assign columns dynamically
74
+ with cols[i % 3]:
75
+ st.image(product_image, caption=f"Product {i + 1}")
76
+ else:
77
+ # If the image does not exist, skip it
78
+ st.write(f"Image for Product {i + 1} not found.")