Spaces:
Paused
Paused
giorgio-caparvi
commited on
Commit
·
6baa8bf
1
Parent(s):
e9c985d
updated path to save sketch and then reading file
Browse files
api/model/src/datasets/dresscode.py
CHANGED
@@ -83,28 +83,42 @@ class DressCodeDataset(data.Dataset):
|
|
83 |
'''
|
84 |
|
85 |
# Load Captions
|
86 |
-
model_data = self.json_from_req.get('
|
87 |
# Filter captions based on the length requirement (3 or more items)
|
88 |
self.captions_dict = {k: v for k, v in model_data.items() if len(v) >= 3}
|
89 |
|
90 |
-
|
91 |
-
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
|
109 |
self.im_names = im_names
|
110 |
self.c_names = c_names
|
|
|
83 |
'''
|
84 |
|
85 |
# Load Captions
|
86 |
+
model_data = self.json_from_req.get('dresscode', {}) # Safely get the 'MODEL' key, default to an empty dictionary if it doesn't exist
|
87 |
# Filter captions based on the length requirement (3 or more items)
|
88 |
self.captions_dict = {k: v for k, v in model_data.items() if len(v) >= 3}
|
89 |
|
90 |
+
# Retrieving bodypart sketch: dresses, upper_body, lower_body
|
91 |
+
body_part = self.json_from_req.get('body_part', '')
|
92 |
|
93 |
+
#for c in category:
|
94 |
+
# assert c in ['dresses', 'upper_body', 'lower_body']
|
95 |
+
|
96 |
+
dataroot = self.dataroot / body_part
|
97 |
+
#if phase == 'train':
|
98 |
+
# filename = dataroot / f"{phase}_pairs.txt"
|
99 |
+
#else:
|
100 |
+
# filename = dataroot / f"{phase}_pairs_{order}.txt"
|
101 |
+
|
102 |
+
# Creating new file name
|
103 |
+
filename = dataroot / "test_pairs_paired.txt"
|
104 |
+
|
105 |
+
with open(filename, 'w') as f:
|
106 |
+
first_key = list(model_data.keys())[0]
|
107 |
+
img_name1 = f"{first_key}_0.jpg"
|
108 |
+
img_name2 = f"{first_key}_1.jpg"
|
109 |
+
|
110 |
+
print("########################################### ", img_name1)
|
111 |
+
f.write(f"{img_name1} {img_name2}\n")
|
112 |
|
113 |
+
with open(filename, 'r') as f:
|
114 |
+
for line in f.readlines():
|
115 |
+
im_name, c_name = line.strip().split()
|
116 |
+
if c_name.split('_')[0] not in self.captions_dict:
|
117 |
+
continue
|
118 |
|
119 |
+
im_names.append(im_name)
|
120 |
+
c_names.append(c_name)
|
121 |
+
dataroot_names.append(dataroot)
|
122 |
|
123 |
self.im_names = im_names
|
124 |
self.c_names = c_names
|