diff --git a/object_detection/detectron2_training-kfold.ipynb b/object_detection/detectron2_training-kfold.ipynb index 66c1567..5e4e8aa 100644 --- a/object_detection/detectron2_training-kfold.ipynb +++ b/object_detection/detectron2_training-kfold.ipynb @@ -215,6 +215,8 @@ " \n", " def data_loader_mapper(self, batch):\n", " return batch\n", + " \n", + "\n", "\n", " def run_hooks(self):\n", " val_loss = self.validation()\n", @@ -229,8 +231,9 @@ " self._trainer.has_finished = True\n", "\n", " def validation(self):\n", - " val_loader = build_detection_test_loader(self.cfg, self.cfg.DATASETS.TEST[0], evaluators=[evaluator])\n", + " # Define evaluator here\n", " evaluator = COCOEvaluator(self.cfg.DATASETS.TEST[0], self.cfg, True, output_dir=\"./output/\")\n", + " val_loader = build_detection_test_loader(self.cfg, self.cfg.DATASETS.TEST[0], evaluators=[evaluator])\n", " val_results = self._trainer.test(self.cfg, self.model, evaluators=[evaluator])[0]\n", " val_loss = val_results[\"total_loss\"]\n", " return val_loss\n", @@ -256,9 +259,13 @@ " cfg.SOLVER.STEPS = [] # milestones where LR is reduced, in this case there's no decay\n", " cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 128 # The \"RoIHead batch size\". \n", " cfg.MODEL.ROI_HEADS.NUM_CLASSES = 80 \n", - " cfg.TEST.EVAL_PERIOD = 500\n", + " cfg.TEST.EVAL_PERIOD = 15000\n", " os.makedirs(cfg.OUTPUT_DIR, exist_ok=True)\n", " trainer = Early_stopping(cfg, early_stop_patience=5, model_checkpoint_path=\"model_checkpoint.pth\")\n", + " # Specify evaluators during testing\n", + " evaluator = COCOEvaluator(cfg.DATASETS.TEST[0], cfg, True, output_dir=\"./output/\")\n", + " trainer.resume_or_load(resume=False)\n", + " trainer.test(cfg, trainer.model, evaluators=[evaluator])\n", " trainer.resume_or_load(resume=False)\n", " trainer.train();\n", " return cfg\n"