實例分割 模型訓練 InstanceSegmentation by detectron2
detectron2_repo_path = "" #detectron2 path img_path = r"coco/images/train" json_path = r"coco/annotations/instances_train.json" register_coco_instances ( "mydata" , {}, json_path , img_path ) mydata_metadata = MetadataCatalog . get ( "mydata" ) dataset_dicts = DatasetCatalog . get ( "mydata" ) # test data val_img_path = r"coco/images/val2017" val_json_path = r"/coco/annotations/instances_val2017.json" register_coco_instances ( "testdata" , {}, val_json_path , val_img_path ) mydata_metadata = MetadataCatalog . get ( "testdata" ) dataset_dicts = DatasetCatalog . get ( "testdata" ) #註冊自己的數據集 cfg = get_cfg () cfg . merge_from_file ( os . path . join ( detectron2_repo_path , "configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml" ) ) # github有提供不同骨幹:FPN,C4,DC5, cfg . DATASETS . TRAIN = ( ...