yurii_l commited on
Commit
c17d554
·
1 Parent(s): 4bb166c

added fix with png images

Browse files
Files changed (2) hide show
  1. app.py +9 -0
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  import boto3
3
  import streamlit as st
4
  import faiss
@@ -6,6 +7,7 @@ import pandas as pd
6
  from PIL import Image
7
  from model_prediction import Ranker
8
  from io import BytesIO
 
9
 
10
 
11
  @st.cache
@@ -63,6 +65,13 @@ bucket_name = "product-retrieval"
63
 
64
  if uploaded_file is not None:
65
  image = Image.open(uploaded_file)
 
 
 
 
 
 
 
66
  st.image(image, caption="Uploaded image", use_column_width=True)
67
 
68
  loading_text.text("Loading predictions...")
 
1
  import os
2
+ import numpy as np
3
  import boto3
4
  import streamlit as st
5
  import faiss
 
7
  from PIL import Image
8
  from model_prediction import Ranker
9
  from io import BytesIO
10
+ import cv2
11
 
12
 
13
  @st.cache
 
65
 
66
  if uploaded_file is not None:
67
  image = Image.open(uploaded_file)
68
+ image = np.asarray(image)
69
+
70
+ if len(image.shape) > 2 and image.shape[2] == 4:
71
+ image = cv2.cvtColor(image, cv2.COLOR_BGRA2BGR)
72
+
73
+ image = Image.fromarray(image)
74
+
75
  st.image(image, caption="Uploaded image", use_column_width=True)
76
 
77
  loading_text.text("Loading predictions...")
requirements.txt CHANGED
@@ -5,4 +5,5 @@ Pillow
5
  scikit-learn
6
  torchvision
7
  torch
8
- open_clip_torch
 
 
5
  scikit-learn
6
  torchvision
7
  torch
8
+ open_clip_torch
9
+ opencv-python