Detectron2 Custom Object Detection + Sahi #927
Answered
by
HauCongNguyen
drdoof2019
asked this question in
Q&A
-
I am using colab. I trained detectron2 for custom object detection (1 class named "hata") and got "best.pth" file in my google drive. I mounted drive and used the code below:
|
Beta Was this translation helpful? Give feedback.
Answered by
HauCongNguyen
Sep 5, 2023
Replies: 1 comment 4 replies
-
Did you solve it ? I had the answer. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can add the following code to the detectron2 config, and you will get config.yaml file. The config_path is the path to config.yaml :
from sahi.utils.detectron2 import export_cfg_as_yaml
export_cfg_as_yaml(cfg, export_path='config.yaml')
Ex:
cfg = get_cfg()
cfg.merge_from_file(model_zoo.get_config_file("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml"))
cfg.DATASETS.TRAIN = ("",)
cfg.DATASETS.TEST = ("",)
cfg.DATALOADER.NUM_WORKERS = 2
.............
cfg.SOLVER.GAMMA = 0.05
cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 64
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 1
cfg.TEST.EVAL_PERIOD=500
#export config.yaml
from sahi.utils.detectron2 import export_cfg_as_yaml
export_cfg_as_yaml(cfg, export_path='co…