Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit f17c700

Browse files
author
tefenet
committed
index by word, consultant and/or repetition
1 parent 0c0c696 commit f17c700

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

examples/test_basics.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sldatasets as sld
22

3-
dataset = sld.get("asllvd")
3+
dataset = sld.get("asllvd", word='Twenty', consultant='liz')
44
print("dataset summary:")
55
dataset.summary()
66
for video, description in dataset:
@@ -9,14 +9,20 @@
99
frame, frame_annot = video[3]
1010
print('frame shape: ', frame.shape)
1111
print('estimated body parts (x,y,score): ')
12+
# this method pretty print a Dictionary that returns the method frame_annot.get()
1213
frame_annot.pretty()
14+
1315
face = frame_annot.h.get_face_box(640, 480)
1416
print('face box: ', face)
15-
print(frame_annot.h.get_upper_body_box(640, 480))
16-
# dataset = sld.get("lsa64", version='pre')
17-
# dataset.summary()
18-
# for video, description in dataset:
19-
# print(description)
20-
# frame, frame_annot = video[3]
21-
# print(frame.shape)
22-
# print(frame_annot)
17+
print('upper body box: ', frame_annot.h.get_upper_body_box(640, 480))
18+
19+
print('\n testing lsa64...')
20+
dataset = sld.get("lsa64", version='cut', word=25,
21+
consultant=10, repetition=5)
22+
dataset.summary()
23+
for video, description in dataset:
24+
print(description)
25+
frame, frame_annot = video[3]
26+
print('frame shape: ', frame.shape)
27+
print('estimated body parts (x,y,score): ')
28+
frame_annot.pretty()

sldatasets/datasethandler.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ def redux(self, files, **kwargs):
4646

4747
def file_filter(self, f, clas, consultant, repetition):
4848
d_specs = self.video_info(f)
49-
return ((int(self.word_class(d_specs)) == int(clas) if clas else True) and
50-
(int(self.consultant_of(d_specs)) == consultant if consultant else True) and
51-
(int(self.rept(d_specs)) == repetition if repetition else True))
49+
try:
50+
clas=clas.lower()
51+
consultant=consultant.lower()
52+
finally:
53+
return ((self.word_class(d_specs) == clas if clas else True) and
54+
(self.consultant_of(d_specs) == consultant if consultant else True) and
55+
(self.rept(d_specs) == repetition if repetition else True))
5256
l = list(filter(lambda f: file_filter(
53-
self, f, kwargs.get('index'), kwargs.get('consultant'), kwargs.get('repetition')), l))
57+
self, f, kwargs.get('word'), kwargs.get('consultant'), kwargs.get('repetition')), l))
5458
return l
5559

5660
def specs_from(self, filename):
@@ -111,9 +115,9 @@ def get_my_file_ext(self):
111115
def video_info(self,filename):
112116
splited = filename.split('_')
113117
info_dict={}
114-
info_dict['class']= splited[0]
115-
info_dict['consultant']= splited[1]
116-
info_dict['repetition'] = splited[2].split('.')[0]
118+
info_dict['class']= int(splited[0])
119+
info_dict['consultant']= int(splited[1])
120+
info_dict['repetition'] = int(splited[2].split('.')[0])
117121
return info_dict
118122

119123

@@ -133,9 +137,9 @@ def get_pos_url(self):
133137
def video_info(self, filename):
134138
splited = filename.split('_')
135139
info_dict = {}
136-
info_dict['class']= splited[0]
137-
info_dict['consultant']= splited[1]
138-
info_dict['repetition'] = splited[2]
140+
info_dict['class']= int(splited[0])
141+
info_dict['consultant']= int(splited[1])
142+
info_dict['repetition'] = int(splited[2])
139143
info_dict['hand'] = splited[3].split('.')[0]
140144
return info_dict
141145

@@ -197,10 +201,10 @@ def video_info(self, filename):
197201
return self.dframe.loc[:, 'Consultant':'Passive Arm'][(self.dframe.Filename == filename)].to_dict('records')[0]
198202

199203
def consultant_of(self, d):
200-
return d['Consultant']
204+
return d['Consultant'].lower()
201205

202206
def word_class(self, d):
203-
return d['Main_Gloss']
207+
return d['Main_Gloss'].lower()
204208

205209
def rept(self, d):
206210
return None

sldatasets/video_dataset.py

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ def send(self, ignored_arg):
2525
for f in frames:
2626
l.append((f, anotation[anot_index]))
2727
return (l, specs)
28-
except ModuleNotFoundError:
29-
print(anotation[anot_index].__class__)
3028

3129
def throw(self, type=None, value=None, traceback=None):
3230
raise StopIteration

0 commit comments

Comments
 (0)