activitynet / ActivityNet

This repository is intended to host tools and demos for ActivityNet
MIT License
944 stars 330 forks source link

how to download part of dataset? #82

Closed ronghui19 closed 3 years ago

ronghui19 commented 3 years ago

HI i just want to download part of dataset, for example, play basketball. how should i modify the code to download it?

ronghui19 commented 3 years ago

`from collections import OrderedDict import json

get_dict = OrderedDict()

ann_file = 'activity_net.v1-3.min.json' with open(ann_file, "r") as fobj: anet_v_1_0 = json.load(fobj) all_keys = anet_v_1_0["database"].keys() for key in all_keys: annotations = anet_v_1_0["database"][key]['annotations'] if len(annotations) != 0: if annotations[0]['label'] == 'Layup drill in basketball': get_dict[key] = anet_v_1_0["database"][key]

with open("basketball.json", "w") as outfile:
json.dump(get_dict, outfile) `