how to set the validation ? #2523
Unanswered
leesangjoon1
asked this question in
Q&A
Replies: 1 comment
-
You need to set DATASETS.TRAIN and DATASETS.TEST in your config file. See here |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
import logging
import os
from collections import OrderedDict
import torch
import detectron2.utils.comm as comm
from detectron2.checkpoint import DetectionCheckpointer
from detectron2.config import get_cfg
from detectron2.data import MetadataCatalog
from detectron2.engine import DefaultTrainer, default_argument_parser, default_setup, hooks, launch
from detectron2.evaluation import (
CityscapesInstanceEvaluator,
CityscapesSemSegEvaluator,
COCOEvaluator,
COCOPanopticEvaluator,
DatasetEvaluators,
LVISEvaluator,
PascalVOCDetectionEvaluator,
SemSegEvaluator,
verify_results,
)
from detectron2.modeling import GeneralizedRCNNWithTTA
from detectron2.modeling import GeneralizedRCNNWithTTA
from detectron2.data.datasets import register_coco_instances
register_coco_instances("data_train", {}, "/home/sangjoon/detectron2/sangjoon/real_white_train_jpg.json", "/home/sangjoon/detectron2/sangjoon/real_white_train")
register_coco_instances("data_val", {}, "/home/sangjoon/detectron2/sangjoon/real_white_val_jpg.json", "/home/sangjoon/detectron2/sangjoon/real_white_val")
class Trainer(DefaultTrainer):
"""
We use the "DefaultTrainer" which contains pre-defined default logic for
standard training workflow. They may not work for you, especially if you
are working on a new research project. In that case you can write your
own training loop. You can use "tools/plain_train_net.py" as an example.
"""
def setup(args):
"""
Create configs and perform basic setups.
"""
cfg = get_cfg()
cfg.merge_from_file(args.config_file)
cfg.merge_from_list(args.opts)
cfg.freeze()
default_setup(cfg, args)
return cfg
def main(args):
cfg = setup(args)
if name == "main":
args = default_argument_parser().parse_args()
print("Command Line Args:", args)
launch(
main,
args.num_gpus,
num_machines=args.num_machines,
machine_rank=args.machine_rank,
dist_url=args.dist_url,
args=(args,),
)
This is detectron2 tools/train_net.py file.
I heard that train_net.py already supports validation set at #358
but I wonder where is that code? and I have never set the validation set.
Is it separated at data_train? or data_val?
I set the two code
register_coco_instances("data_train", {}, "/home/sangjoon/detectron2/sangjoon/real_white_train_jpg.json", "/home/sangjoon/detectron2/sangjoon/real_white_train")
register_coco_instances("data_val", {}, "/home/sangjoon/detectron2/sangjoon/real_white_val_jpg.json", "/home/sangjoon/detectron2/sangjoon/real_white_val")
but I have known that "data_train" is just for training and "data_val" is for test
Is it wrong? If it is wrong, please tell me how to compute validation
Thank you
Beta Was this translation helpful? Give feedback.
All reactions