Spaces:
Runtime error
Runtime error
cv2
Browse files- app.py +1 -4
- requirements.txt +1 -2
app.py
CHANGED
@@ -31,7 +31,6 @@ from misc.utils import show_imgs
|
|
31 |
import sys
|
32 |
from misc.dataset import TextEncoder
|
33 |
import requests
|
34 |
-
import cv2
|
35 |
from io import BytesIO
|
36 |
from translate import Translator
|
37 |
|
@@ -54,8 +53,6 @@ def download_url_img(url):
|
|
54 |
return False, []
|
55 |
if response is not None and response.status_code == 200:
|
56 |
input_image_data = response.content
|
57 |
-
# np_arr = np.asarray(bytearray(input_image_data), np.uint8).reshape(1, -1)
|
58 |
-
# parsed_image = cv2.imdecode(np_arr, cv2.IMREAD_UNCHANGED)
|
59 |
image=Image.open(BytesIO(input_image_data))
|
60 |
return True, image
|
61 |
return False, []
|
@@ -74,7 +71,7 @@ def search(mode, text):
|
|
74 |
with torch.no_grad():
|
75 |
_, output_emb = join_emb(None, input_caps, length)
|
76 |
caps_enc.append(output_emb.cpu().data.numpy())
|
77 |
-
|
78 |
caps_stack = np.vstack(caps_enc)
|
79 |
|
80 |
imgs_url = [os.path.join("http://images.cocodataset.org/train2017", img_path.strip().split('_')[-1]) for img_path in imgs_path]
|
|
|
31 |
import sys
|
32 |
from misc.dataset import TextEncoder
|
33 |
import requests
|
|
|
34 |
from io import BytesIO
|
35 |
from translate import Translator
|
36 |
|
|
|
53 |
return False, []
|
54 |
if response is not None and response.status_code == 200:
|
55 |
input_image_data = response.content
|
|
|
|
|
56 |
image=Image.open(BytesIO(input_image_data))
|
57 |
return True, image
|
58 |
return False, []
|
|
|
71 |
with torch.no_grad():
|
72 |
_, output_emb = join_emb(None, input_caps, length)
|
73 |
caps_enc.append(output_emb.cpu().data.numpy())
|
74 |
+
|
75 |
caps_stack = np.vstack(caps_enc)
|
76 |
|
77 |
imgs_url = [os.path.join("http://images.cocodataset.org/train2017", img_path.strip().split('_')[-1]) for img_path in imgs_path]
|
requirements.txt
CHANGED
@@ -9,5 +9,4 @@ torch==1.7.1
|
|
9 |
torchvision==0.8.2
|
10 |
tqdm==4.63.0
|
11 |
translate==3.6.1
|
12 |
-
visual_genome==1.1.1
|
13 |
-
opencv-python
|
|
|
9 |
torchvision==0.8.2
|
10 |
tqdm==4.63.0
|
11 |
translate==3.6.1
|
12 |
+
visual_genome==1.1.1
|
|