Error in running inference.
sfarkya opened this issue · 7 comments
Hello Dear Authors,
Thank you for providing your codebase.
I have been trying to replicate your results.
To start with, I am trying to run inference using the command (in shell)
MASK_RCNN_MODEL=../../../models/MIMDet/VITB-MASKRCNM/benchmarking_mask_rcnn_base_FPN_100ep_LSJ_mae.pth
CONFIG_FILE=./configs/benchmarking/benchmarking_mask_rcnn_base_FPN_100ep_LSJ_mae.py
GPU_NUM=1
output_dir=../../../models/MIMDet/VITB-MASKRCNM/dum_test/
python lazyconfig_train_net.py --config-file $CONFIG_FILE --num-gpus $GPU_NUM --eval-only train.init_checkpoint=$MASK_RCNN_MODEL train.output_dir=$output_dir
MASK_RCNN_MODEL is downloaded from your main page here: https://github.com/hustvl/MIMDet#mask-r-cnn
I am getting this error:
Traceback (most recent call last):
File "lazyconfig_train_net.py", line 136, in <module>
args=(args,),
File "/usr/local/lib/python3.7/dist-packages/detectron2/engine/launch.py", line 82, in launch
main_func(*args)
File "lazyconfig_train_net.py", line 110, in main
model = instantiate(cfg.model)
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in instantiate
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in <dictcomp>
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in instantiate
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in <dictcomp>
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 77, in instantiate
return cls(**cfg)
File "/root/data/saurabh/code/workdir/MIMDet/models/benchmarking.py", line 500, in __init__
checkpoint = torch.load(pretrained, map_location="cpu")
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 594, in load
with _open_file_like(f, 'rb') as opened_file:
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 211, in __init__
super(_open_file, self).__init__(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'pretrained/mae_pretrain_vit_base.pth'
Now, I am not sure why it's looking for mae_pretrained_vit_base model for inference?
Also, how is model.backbone.bottom_up.pretrained is different from train.pretrained variable in your config?
I tried to fix that by passing the same model path to that variable like this:
MASK_RCNN_MODEL=../../../models/MIMDet/VITB-MASKRCNM/benchmarking_mask_rcnn_base_FPN_100ep_LSJ_mae.pth
CONFIG_FILE=./configs/benchmarking/benchmarking_mask_rcnn_base_FPN_100ep_LSJ_mae.py
GPU_NUM=1
output_dir=../../../models/MIMDet/VITB-MASKRCNM/dum_test/
# inference
python lazyconfig_train_net.py --config-file $CONFIG_FILE --num-gpus $GPU_NUM --eval-only train.init_checkpoint=$MASK_RCNN_MODEL model.backbone.bottom_up.pretrained=$MASK_RCNN_MODEL train.output_dir=$output_dir
I am not sure whether this is correct or not. Assuming it then I get this error:
Traceback (most recent call last):
File "lazyconfig_train_net.py", line 136, in <module>
args=(args,),
File "/usr/local/lib/python3.7/dist-packages/detectron2/engine/launch.py", line 82, in launch
main_func(*args)
File "lazyconfig_train_net.py", line 110, in main
model = instantiate(cfg.model)
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in instantiate
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in <dictcomp>
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in instantiate
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in <dictcomp>
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 77, in instantiate
return cls(**cfg)
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/config.py", line 192, in wrapped
init_func(self, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/detectron2/modeling/roi_heads/box_head.py", line 49, in __init__
self._output_size = (input_shape.channels, input_shape.height, input_shape.width)
File "/usr/local/lib/python3.7/dist-packages/omegaconf/listconfig.py", line 185, in __getattr__
"ListConfig does not support attribute access"
File "/usr/local/lib/python3.7/dist-packages/omegaconf/base.py", line 237, in _format_and_raise
type_override=type_override,
File "/usr/local/lib/python3.7/dist-packages/omegaconf/_utils.py", line 873, in format_and_raise
_raise(ex, cause)
File "/usr/local/lib/python3.7/dist-packages/omegaconf/_utils.py", line 771, in _raise
raise ex.with_traceback(sys.exc_info()[2]) # set env var OC_CAUSE=1 for full trace
omegaconf.errors.ConfigAttributeError: ListConfig does not support attribute access
full_key: [channels]
object_type=list
This say the model is missing some keys.
Can you please tell me what's the issue with the command I am running.
Thank you in advance!
Hi, @sfarkya! Thanks for your interest in our work.
You can simply set model.backbone.bottom_up.pretrained=''
in config to avoid loading mae pretrained weight.
Hope this can address your issue!
@vealocia I did, but I am getting similar issue.
Command:
MAE_MODEL=../../../models/MIMDet/VITB-MAE/mae_pretrain_vit_base_full.pth
MASK_RCNN_MODEL=../../../models/MIMDet/VITB-MASKRCNM/benchmarking_mask_rcnn_base_FPN_100ep_LSJ_mae.pth
CONFIG_FILE=./configs/benchmarking/benchmarking_mask_rcnn_base_FPN_100ep_LSJ_mae.py
GPU_NUM=1
output_dir=../../../models/MIMDet/VITB-MASKRCNM/dum_test/
# inference
python lazyconfig_train_net.py --config-file $CONFIG_FILE --num-gpus $GPU_NUM --eval-only train.init_checkpoint=$MASK_RCNN_MODEL train.output_dir=$output_dir model.backbone.bottom_up.pretrained=''
Error:
Traceback (most recent call last):
File "lazyconfig_train_net.py", line 136, in <module>
args=(args,),
File "/usr/local/lib/python3.7/dist-packages/detectron2/engine/launch.py", line 82, in launch
main_func(*args)
File "lazyconfig_train_net.py", line 110, in main
model = instantiate(cfg.model)
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in instantiate
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in <dictcomp>
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in instantiate
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 61, in <dictcomp>
cfg = {k: instantiate(v) for k, v in cfg.items()}
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/instantiate.py", line 77, in instantiate
return cls(**cfg)
File "/usr/local/lib/python3.7/dist-packages/detectron2/config/config.py", line 192, in wrapped
init_func(self, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/detectron2/modeling/roi_heads/box_head.py", line 49, in __init__
self._output_size = (input_shape.channels, input_shape.height, input_shape.width)
File "/usr/local/lib/python3.7/dist-packages/omegaconf/listconfig.py", line 185, in __getattr__
"ListConfig does not support attribute access"
File "/usr/local/lib/python3.7/dist-packages/omegaconf/base.py", line 237, in _format_and_raise
type_override=type_override,
File "/usr/local/lib/python3.7/dist-packages/omegaconf/_utils.py", line 873, in format_and_raise
_raise(ex, cause)
File "/usr/local/lib/python3.7/dist-packages/omegaconf/_utils.py", line 771, in _raise
raise ex.with_traceback(sys.exc_info()[2]) # set env var OC_CAUSE=1 for full trace
omegaconf.errors.ConfigAttributeError: ListConfig does not support attribute access
full_key: [channels]
object_type=list
Here's the solution for the issue facebookresearch/detectron2#4254
The omegaconf version is the problem! Maybe you can update your dependencies.
" detectron installs omegaconf==2.2.1 and downgrading to omegaconf==2.1 "
I will close this issue, but before that can you please tell me how I can change the path for COCO validation JSON?
default is looking at
datasets/coco/annotations/instances_val2017.json
but I am unable to find a variable in your config file to change the path to some other location or custom dataset.
Thanks again!
Solved here: #18 (comment)
Solution: set the env variable DETECTRON2_DATASETS
Results on COCO-2017 validation set:
| AP | AP50 | AP75 | APs | APm | APl |
|:------:|:------:|:------:|:------:|:------:|:------:|
| 50.376 | 70.887 | 55.699 | 34.429 | 54.226 | 64.987 |
[05/25 15:28:14] d2.evaluation.coco_evaluation INFO: Per-category bbox AP:
| category | AP | category | AP | category | AP |
|:--------------|:-------|:-------------|:-------|:---------------|:-------|
| person | 60.493 | bicycle | 39.675 | car | 51.847 |
| motorcycle | 53.203 | airplane | 74.333 | bus | 73.277 |
| train | 71.992 | truck | 44.949 | boat | 33.246 |
| traffic light | 32.218 | fire hydrant | 73.344 | stop sign | 73.015 |
| parking meter | 48.666 | bench | 35.641 | bird | 43.602 |
| cat | 73.942 | dog | 71.209 | horse | 69.630 |
| sheep | 59.972 | cow | 64.537 | elephant | 72.623 |
| bear | 74.706 | zebra | 71.622 | giraffe | 72.974 |
| backpack | 23.733 | umbrella | 46.280 | handbag | 24.222 |
| tie | 44.558 | suitcase | 53.389 | frisbee | 72.494 |
| skis | 34.476 | snowboard | 46.419 | sports ball | 53.626 |
| kite | 51.465 | baseball bat | 42.996 | baseball glove | 44.681 |
| skateboard | 61.793 | surfboard | 48.079 | tennis racket | 60.592 |
| bottle | 46.062 | wine glass | 44.837 | cup | 50.103 |
| fork | 50.039 | knife | 32.967 | spoon | 30.692 |
| bowl | 48.170 | banana | 25.615 | apple | 29.153 |
| sandwich | 44.244 | orange | 32.416 | broccoli | 26.587 |
| carrot | 25.332 | hot dog | 45.608 | pizza | 57.108 |
| donut | 56.846 | cake | 47.720 | chair | 40.098 |
| couch | 50.060 | potted plant | 35.661 | bed | 54.436 |
| dining table | 33.875 | toilet | 65.613 | tv | 65.459 |
| laptop | 69.175 | mouse | 66.428 | remote | 44.127 |
| keyboard | 60.966 | cell phone | 45.836 | microwave | 67.998 |
| oven | 41.615 | toaster | 42.862 | sink | 44.285 |
| refrigerator | 68.077 | book | 21.948 | clock | 50.968 |
| vase | 43.009 | scissors | 45.562 | teddy bear | 60.708 |
| hair drier | 27.178 | toothbrush | 41.125 | | |
Hopefully, this is close to the performance you are getting.