Last active
August 2, 2020 15:49
-
-
Save aakarsh7599/269bfdb11c59c591d86d7ee512a9d3fb 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
from detectron2.engine import DefaultTrainer | |
from detectron2.config import get_cfg | |
import os | |
cfg = get_cfg() | |
cfg.merge_from_file(model_zoo.get_config_file("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml")) #Get the basic model configuration from the model zoo | |
#Passing the Train and Validation sets | |
cfg.DATASETS.TRAIN = ("boardetect_train",) | |
cfg.DATASETS.TEST = ("boardetect_val",) | |
# Number of data loading threads | |
cfg.DATALOADER.NUM_WORKERS = 4 | |
cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml") # Let training initialize from model zoo | |
# Number of images per batch across all machines. | |
cfg.SOLVER.IMS_PER_BATCH = 4 | |
cfg.SOLVER.BASE_LR = 0.0125 # pick a good LearningRate | |
cfg.SOLVER.MAX_ITER = 1500 #No. of iterations | |
cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 256 | |
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 3 # No. of classes = [HINDI, ENGLISH, OTHER] | |
cfg.TEST.EVAL_PERIOD = 500 # No. of iterations after which the Validation Set is evaluated. | |
os.makedirs(cfg.OUTPUT_DIR, exist_ok=True) | |
trainer = CocoTrainer(cfg) | |
trainer.resume_or_load(resume=False) | |
trainer.train() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment