Spaces:
Sleeping
Sleeping
Commit
·
eccac7a
1
Parent(s):
087f23f
Update app.py
Browse files
app.py
CHANGED
@@ -10,27 +10,35 @@ import pandas as pd
|
|
10 |
import pickle
|
11 |
import pickletools
|
12 |
from transformers import AutoTokenizer, CLIPTextModelWithProjection
|
|
|
13 |
|
14 |
# loading the train dataset
|
15 |
-
|
16 |
-
|
17 |
# train_xv = temp_d['image'].astype(np.float64) # Array of image features : np ndarray
|
18 |
# train_xt = temp_d['text'].astype(np.float64) # Array of text features : np ndarray
|
19 |
# train_yv = temp_d['label'] # Array of labels
|
20 |
-
|
21 |
# ids = list(temp_d['ids']) # image names == len(images)
|
22 |
|
23 |
-
train_yt = np.load("train_yt.npy")
|
24 |
|
25 |
# loading the test dataset
|
26 |
-
|
27 |
-
|
28 |
# test_xv = temp_d['image'].astype(np.float64)
|
29 |
# test_xt = temp_d['text'].astype(np.float64)
|
30 |
# test_yv = temp_d['label']
|
31 |
-
|
32 |
|
33 |
-
test_xt = np.load("test_xt.npy")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
# Map the image ids to the corresponding image URLs
|
36 |
image_map_name = 'pascal_dataset.csv'
|
|
|
10 |
import pickle
|
11 |
import pickletools
|
12 |
from transformers import AutoTokenizer, CLIPTextModelWithProjection
|
13 |
+
from sklearn.preprocessing import normalize, OneHotEncoder
|
14 |
|
15 |
# loading the train dataset
|
16 |
+
with open('clip_train.pkl', 'rb') as f:
|
17 |
+
temp_d = pickle.load(f)
|
18 |
# train_xv = temp_d['image'].astype(np.float64) # Array of image features : np ndarray
|
19 |
# train_xt = temp_d['text'].astype(np.float64) # Array of text features : np ndarray
|
20 |
# train_yv = temp_d['label'] # Array of labels
|
21 |
+
train_yt = temp_d['label'] # Array of labels
|
22 |
# ids = list(temp_d['ids']) # image names == len(images)
|
23 |
|
24 |
+
# train_yt = np.load("train_yt.npy")
|
25 |
|
26 |
# loading the test dataset
|
27 |
+
with open('clip_test.pkl', 'rb') as f:
|
28 |
+
temp_d = pickle.load(f)
|
29 |
# test_xv = temp_d['image'].astype(np.float64)
|
30 |
# test_xt = temp_d['text'].astype(np.float64)
|
31 |
# test_yv = temp_d['label']
|
32 |
+
test_yt = temp_d['label']
|
33 |
|
34 |
+
# test_xt = np.load("test_xt.npy")
|
35 |
+
|
36 |
+
enc = OneHotEncoder(sparse=False)
|
37 |
+
enc.fit(np.concatenate((train_yt, test_yt)).reshape((-1, 1)))
|
38 |
+
# train_yv = enc.transform(self.train_yv.reshape((-1, 1))).astype(np.float64)
|
39 |
+
# test_yv = enc.transform(self.test_yv.reshape((-1, 1))).astype(np.float64)
|
40 |
+
# train_yt = enc.transform(self.train_yt.reshape((-1, 1))).astype(np.float64)
|
41 |
+
test_yt = enc.transform(self.test_yt.reshape((-1, 1))).astype(np.float64)
|
42 |
|
43 |
# Map the image ids to the corresponding image URLs
|
44 |
image_map_name = 'pascal_dataset.csv'
|