Detectron2-物件辨識模型訓練
註冊數據集 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 )) MetadataCatal...