![]() imread ( d ) outputs = predictor ( im ) v = Visualizer ( im, metadata = fruits_nuts_metadata, scale = 0.8, instance_mode = ColorMode. First, let's create a predictor using the model we just trained:įrom import ColorMode for d in random. Now, we perform inference with the trained model on the fruits_nuts dataset. ![]() In case you switch to your own datasets, change the number of classes, learning rate, or max iterations accordingly. resume_or_load ( resume = False ) trainer. ![]() OUTPUT_DIR, exist_ok = True ) trainer = DefaultTrainer ( cfg ) trainer. NUM_CLASSES = 3 # 3 classes (data, fig, hazelnut) os. BATCH_SIZE_PER_IMAGE = ( 128 ) # faster, and good enough for this toy dataset cfg. MAX_ITER = ( 300 ) # 300 iterations seems good enough, but you can certainly train longer cfg. WEIGHTS = "detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl" # initialize from model zoo cfg. TEST = () # no metrics implemented for this dataset cfg. merge_from_file ( "./detectron2_repo/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml" ) cfg. From detectron2.engine import DefaultTrainer from nfig import get_cfg import os cfg = get_cfg () cfg.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |