Pairavi commited on
Commit
0560cab
·
1 Parent(s): 8d4e1cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
app.py CHANGED
@@ -126,22 +126,24 @@ def main():
126
  start_index = (tabs - 1) * images_per_page
127
  end_index = min(start_index + images_per_page, length)
128
 
129
- # Loop through each similar image
130
- for index in range(start_index, end_index):
131
- img_id = similar_images[index]
132
- img_path = df.loc[df['seller_img_id'] == img_id, 'img_path'].values[0]
133
- product_id = df.loc[df['seller_img_id'] == img_id, 'product_id'].values[0]
134
-
135
- # Construct the full path to the image
136
- full_img_path = img_path
137
-
138
- # Open and resize the image to the desired dimensions
139
- image = image_open(full_img_path)
140
- resized_image = cv2.resize(image, (image_width, image_height))
141
-
142
- # Determine the column to place the image in
143
- col_index = index % num_columns
144
- st.image(resized_image, caption=f'Product ID: {product_id}\nImage ID: {img_id}', width=image_width)
 
 
145
 
146
 
147
  if __name__ == '__main__':
 
126
  start_index = (tabs - 1) * images_per_page
127
  end_index = min(start_index + images_per_page, length)
128
 
129
+ for img_id in similar_images:
130
+ row = df[df['seller_img_id'] == img_id]
131
+ if not row.empty:
132
+ img_path = row['img_path'].values[0]
133
+ product_id = row['product_id'].values[0]
134
+
135
+ # Construct the full path to the image
136
+ full_img_path = img_path
137
+
138
+ # Open and resize the image to the desired dimensions
139
+ image = read_image(full_img_path)
140
+ resized_image = cv2.resize(image, (image_width, image_height))
141
+
142
+ # Determine the column to place the image in
143
+ col_index = index % num_columns
144
+ st.image(resized_image, caption=f'Product ID: {product_id}\nImage ID: {img_id}', width=image_width)
145
+ else:
146
+ st.write(f"Could not find details for image with ID: {img_id}")
147
 
148
 
149
  if __name__ == '__main__':