Pairavi commited on
Commit
bc4fce7
·
1 Parent(s): 56838e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -17,6 +17,15 @@ def read_image(uploaded_file):
17
  os.remove(uploaded_file.name) # Remove the temporary file
18
  return img
19
 
 
 
 
 
 
 
 
 
 
20
 
21
  # Function to display images from their paths
22
  def display_images(image_ids):
@@ -25,7 +34,7 @@ def display_images(image_ids):
25
  for img_id in image_ids:
26
  image_path = df.loc[df['seller_img_id'] == img_id, 'img_path'].values[0]
27
  print(image_path)
28
- image = read_image(image_path)
29
  images.append(image)
30
  captions.append(img_id)
31
  return images, captions
 
17
  os.remove(uploaded_file.name) # Remove the temporary file
18
  return img
19
 
20
+ def image_open(image_file):
21
+ img = cv2.imread(
22
+ image_file, cv2.IMREAD_COLOR | cv2.IMREAD_IGNORE_ORIENTATION
23
+ )
24
+ img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
25
+ if img is None:
26
+ raise ValueError('Failed to read {}'.format(image_file))
27
+ return img
28
+
29
 
30
  # Function to display images from their paths
31
  def display_images(image_ids):
 
34
  for img_id in image_ids:
35
  image_path = df.loc[df['seller_img_id'] == img_id, 'img_path'].values[0]
36
  print(image_path)
37
+ image = image_open(image_path)
38
  images.append(image)
39
  captions.append(img_id)
40
  return images, captions