Created
January 24, 2022 16:22
-
-
Save dissagaliyeva/9264455dd07afa4ebf52387d941b8c41 to your computer and use it in GitHub Desktop.
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 convert as via2coco | |
# set class index (can be either 0 or 1) | |
first_class_index = 0 | |
# for those who decided to go with their own annotations | |
# data_path = '/content/annotations/output/' | |
# for those who downloaded from github | |
data_path = '/content/scrapped_data' | |
for keyword in ['train', 'val']: | |
input_dir = data_path + '/' + keyword + '/' | |
input_json = input_dir + 'via_region_data.json' | |
categories = ['cigarette'] | |
super_categories = ['N/A'] | |
# save the standard as custom_train or custom_val | |
output_json = input_dir + 'custom_' + keyword + '.json' | |
print('Converting {} from VIA format to COCO format'.format(input_json)) | |
coco_dict = via2coco.convert( | |
imgdir=input_dir, | |
annpath=input_json, | |
categories=categories, | |
super_categories=super_categories, | |
output_file_name=output_json, | |
first_class_index=first_class_index, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment