Last active
August 2, 2020 15:56
-
-
Save aakarsh7599/5ae5b62b1bdec2c9b34c17cfac2a0b5c 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 json | |
from detectron2.structures import BoxMode | |
def get_board_dicts(imgdir): | |
json_file = imgdir+"/dataset.json" #Fetch the json file | |
with open(json_file) as f: | |
dataset_dicts = json.load(f) | |
for i in dataset_dicts: | |
filename = i["file_name"] | |
i["file_name"] = imgdir+"/"+filename | |
for j in i["annotations"]: | |
j["bbox_mode"] = BoxMode.XYWH_ABS #Setting the required Box Mode | |
j["category_id"] = int(j["category_id"]) | |
return dataset_dicts | |
from detectron2.data import DatasetCatalog, MetadataCatalog | |
#Registering the Dataset | |
for d in ["train", "val"]: | |
DatasetCatalog.register("boardetect_" + d, lambda d=d: get_board_dicts("Text_Detection_Dataset_COCO_Format/" + d)) | |
MetadataCatalog.get("boardetect_" + d).set(thing_classes=["HINDI","ENGLISH","OTHER"]) | |
board_metadata = MetadataCatalog.get("boardetect_train") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment