in lib/datasets/epic.py [0:0]
def load_annotations(is_train):
"""Load EPIC-Kitchens annotations."""
annotations = []
verb_set = set()
noun_set = set()
filename = os.path.join(cfg.EPIC.ANNOTATION_DIR, cfg.EPIC.ANNOTATIONS)
with open(filename, 'rb') as f:
f.readline()
reader = csv.reader(f)
for row in reader:
person = row[1]
if is_train:
if int(person[1:]) not in TRAIN_PERSON_INDICES:
continue
else:
if int(person[1:]) in TRAIN_PERSON_INDICES:
continue
#uid,participant_id,video_id,narration,start_timestamp,stop_timestamp,start_frame,stop_frame,verb,verb_class,noun,noun_class,all_nouns,all_noun_classes
video_name = row[2]
start_frame = sec_to_frame(time_to_sec(row[4]))
stop_frame = sec_to_frame(time_to_sec(row[5]))
verb = int(row[-5])
noun = int(row[-3])
assert verb < NUM_CLASSES_VERB, verb
assert verb >= 0, verb
assert noun < NUM_CLASSES_NOUN, noun
assert noun >= 0, noun
annotations.append(
(person, video_name, start_frame, stop_frame, verb, noun))
verb_set.add(verb)
noun_set.add(noun)
logger.info('See %d verbs and %d nouns in the dataset loaded.' % (
len(verb_set), len(noun_set)))
cur_label_set = verb_set if cfg.EPIC.CLASS_TYPE == 'verb' else noun_set
if len(cur_label_set) != cfg.MODEL.NUM_CLASSES:
logger.warn(
'# classes seen (%d) != MODEL.NUM_CLASSES' % len(cur_label_set))
assert len(annotations) == (cfg.TRAIN.DATASET_SIZE if is_train
else cfg.TEST.DATASET_SIZE)
return annotations