Download hub_data1/krit/data/action-genome/tools/load_annotations.py from Jhp/85: direct link, hf CLI and curl.
- Browser
- Download file 774 Bytes
-
https://huggingface.co/datasets/Jhp/85/resolve/main/hub_data1/krit/data/action-genome/tools/load_annotations.py
- Command line
-
hf download hf://datasets/Jhp/85/hub_data1/krit/data/action-genome/tools/load_annotations.py
-
curl -L -o load_annotations.py https://huggingface.co/datasets/Jhp/85/resolve/main/hub_data1/krit/data/action-genome/tools/load_annotations.py
774 Bytes
| import os | |
| import pickle | |
| def load_annotations(annotation_dir): | |
| with open(os.path.join(annotation_dir, 'object_bbox_and_relationship.pkl'), 'rb') as f: | |
| object_anno = pickle.load(f) | |
| with open(os.path.join(annotation_dir, 'person_bbox.pkl'), 'rb') as f: | |
| person_anno = pickle.load(f) | |
| frame_list = [] | |
| with open(os.path.join(annotation_dir, 'frame_list.txt'), 'r') as f: | |
| for frame in f: | |
| frame_list.append(frame.rstrip('\n')) | |
| return object_anno, person_anno, frame_list | |
| if __name__ == "__main__": | |
| annotation_dir = './annotations' | |
| object_anno, person_anno, frame_list = load_annotations(annotation_dir) | |
| assert set(object_anno.keys()) == set(person_anno.keys()) | |
| assert len(object_anno) == len(frame_list) | |