Skip to content

Instantly share code, notes, and snippets.

View trongan93's full-sized avatar

Trong-An (Andrew) Bui trongan93

View GitHub Profile
cfg.MODEL.WEIGHTS = os.path.join(cfg.OUTPUT_DIR, "model_final.pth") # path to the model we just trained
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.7 # set a custom testing threshold
predictor = DefaultPredictor(cfg)
from detectron2.utils.visualizer import ColorMode
json_file_test = "/mnt/d/RarePlanes/datasets/synthetic/metadata_annotations/instances_test_aircraft.json"
coco_test=COCO(json_file_test)
catIds = coco_test.getCatIds(catNms=['aircraft']);
imgIds = coco_test.getImgIds(catIds=catIds);
img = coco_test.loadImgs(imgIds[np.random.randint(0,len(imgIds))])[0]
im = cv2.imread("/mnt/d/RarePlanes/datasets/synthetic/test/images/" + img['file_name'])
plt.axis('off')