Open spatiallysaying opened 3 years ago
DefaultPredictor
is just for simple demo, so it currently does not support extra color schemes.
As its documentation https://detectron2.readthedocs.io/en/latest/modules/engine.html#detectron2.engine.defaults.DefaultPredictor says:
If you’d like to do anything more fancy, please refer to its source code as examples to build and use the model manually.
@ppwwyyxx, any suggestion on how to go about it? I am assuming that multiple color formats are already supported per the link. https://github.com/facebookresearch/detectron2/issues/url . I am just thinking the if training and inference are correctly put, this should work.
Has any further work been done on using different color schemes with Detectron2 DefaultPredictor? HSV in particular?
Instructions To Reproduce the 🐛 Bug:
class CocoTrainer(DefaultTrainer): @classmethod def build_evaluator(cls, cfg, dataset_name, output_folder=None): cfg.INPUT.FORMAT = "HSV" if output_folder is None: os.makedirs("coco_eval", exist_ok=True) output_folder = "coco_eval"
from detectron2.engine import DefaultTrainer from detectron2.config import get_cfg import os
cfg = get_cfg() cfg.merge_from_file("./detectron2_repo/configs/COCO-Detection/faster_rcnn_R_101_FPN_3x.yaml") cfg.DATASETS.TRAIN = ("rwythr",) cfg.DATASETS.TEST = () # no metrics implemented for this dataset cfg.TEST.EVAL_PERIOD = 100 cfg.DATALOADER.NUM_WORKERS = 2 cfg.MODEL.WEIGHTS = "detectron2://COCO-Detection/faster_rcnn_R_101_FPN_3x/137851257/model_final_f6e8b1.pkl" cfg.SOLVER.IMS_PER_BATCH = 2 cfg.SOLVER.BASE_LR = 0.0002 cfg.SOLVER.MAX_ITER = 10 # 300 iterations seems good enough, but you can certainly train longer cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 128 # faster, and good enough for this toy dataset cfg.MODEL.ROI_HEADS.NUM_CLASSES = 1 cfg.MODEL.DEVICE = "cpu" cfg.INPUT.RANDOM_FLIP = "horizontal"
Cropping type. See documentation of
detectron2.data.transforms.RandomCrop
for explanation.cfg.INPUT.CROP.TYPE = "relative_range"
Size of crop in range (0, 1] if CROP.TYPE is "relative" or "relative_range" and in number of
pixels if CROP.TYPE is "absolute"
cfg.INPUT.CROP.SIZE = [0.9, 0.9] cfg.INPUT.FORMAT = "HSV"
os.makedirs(cfg.OUTPUT_DIR, exist_ok=True) If making changes to the project itself, please use output of the following command: git rev-parse HEAD; git diff