Created
June 10, 2023 13:30
-
-
Save xiaoli/e136b5d63b82854b06066218038f2d90 to your computer and use it in GitHub Desktop.
Filtering bdd100k dataset by timeofday attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def filter_train(): | |
data = [] | |
with open('bdd100k_labels/bdd100k_labels_images_train.json') as f: | |
train = json.load(f) | |
for image in train: | |
if image['attributes']['timeofday'] == 'daytime': | |
data.append(image) | |
new_file = open('bdd100k_labels/bdd100k_labels_images_train_daytime.json', 'w') | |
json.dump(data, new_file, indent=4) | |
new_file.close() | |
def filter_val(): | |
data = [] | |
with open('bdd100k_labels/bdd100k_labels_images_val.json') as f: | |
train = json.load(f) | |
for image in train: | |
if image['attributes']['timeofday'] == 'daytime': | |
data.append(image) | |
new_file = open('bdd100k_labels/bdd100k_labels_images_val_daytime.json', 'w') | |
json.dump(data, new_file, indent=4) | |
new_file.close() | |
if __name__ == '__main__': | |
filter_train() | |
filter_val() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment