ViT-Adapter
ViT-Adapter copied to clipboard
get_flops.py
Hi, I'm trying to use get_flops to get params and flops(MACs * 2).
But, when I ran it with just default setup like only
python get_flops.py
.
Traceback (most recent call last):
File "get_flops.py", line 11, in
error is occured like above.
I followed all the instructions in segmentation folder, and image_demo.py works well. what is the problem?
Hi, I'm trying to use get_flops to get params and flops(MACs * 2).
But, when I ran it with just default setup like only
python get_flops.py
. Traceback (most recent call last): File "get_flops.py", line 11, in import mmdet_custom # noqa: F401,F403 ModuleNotFoundError: No module named 'mmdet_custom'
error is occured like above.
I followed all the instructions in segmentation folder, and image_demo.py works well. what is the problem?
Hi, you can try this command before running the python script:
export PYTHONPATH=/path/to/ViT-Adapter/detection
Replace the /path/to/ViT-Adapter/detection
with the path to the detection folder.
Hi, I'm trying to use get_flops to get params and flops(MACs * 2). But, when I ran it with just default setup like only python get_flops.py . Traceback (most recent call last): File "get_flops.py", line 11, in import mmdet_custom # noqa: F401,F403 ModuleNotFoundError: No module named 'mmdet_custom' error is occured like above. I followed all the instructions in segmentation folder, and image_demo.py works well. what is the problem?
Hi, you can try this command before running the python script:
export PYTHONPATH=/path/to/ViT-Adapter/detection
Replace the/path/to/ViT-Adapter/detection
with the path to the detection folder.
Hey, I try this but
raise KeyError(f'{name} is already registered '
KeyError: 'SinePositionalEncoding is already registered in position encoding'
error like this
Sorry, there seems a bug in the get_flops.py
in the segmentation folder. You can replace import mmdet_custom
with import mmseg_custom
, and add the path to the segmentation folder to PYTHONPATH
.
Sorry, there seems a bug in the
get_flops.py
in the segmentation folder. You can replaceimport mmdet_custom
withimport mmseg_custom
, and add the path to the segmentation folder toPYTHONPATH
.
Thanks.
Btw, could you give me a example code to run get_flops?
I'm using
mask2former_beit_adapter_large_896_80k_mapillary.pth.tar with 360 x 480 img.
Looks quite different from using image_demo.py
I think maybe you can try a command like this:
python tools/get_flops.py configs/cityscapes/mask2former_beit_adapter_large_896_80k_mapillary_ss.py --shape 360 480
I think maybe you can try a command like this:
python tools/get_flops.py configs/cityscapes/mask2former_beit_adapter_large_896_80k_mapillary_ss.py --shape 360 480
python get_flops.py mask2former_beit_adapter_large_896_80k_mapillary.pth.tar --shape 360 480
Traceback (most recent call last):
File "get_flops.py", line 94, in
I changed ur suggestion little bit cuz previous error is ----ss.py is not a check point. so I replaced it as a .pth.tar.
but error like this
The "not a check point" error is caused by the pre-trained checkpoint, not by ".py". When counting flops or parameters, you don't really need a checkpoint file or pretrained file. So you can change
pretrained = 'pretrained/beit_large_patch16_224_pt22k_ft22k.pth'
in configs/cityscapes/mask2former_beit_adapter_large_896_80k_mapillary_ss.py
to pretrained = None
and run
python tools/get_flops.py configs/cityscapes/mask2former_beit_adapter_large_896_80k_mapillary_ss.py --shape 360 480
again.
The "not a check point" error is caused by the pre-trained checkpoint, not by ".py". When counting flops or parameters, you don't really need a checkpoint file or pretrained file. So you can change
pretrained = 'pretrained/beit_large_patch16_224_pt22k_ft22k.pth'
inconfigs/cityscapes/mask2former_beit_adapter_large_896_80k_mapillary_ss.py
topretrained = None
and runpython tools/get_flops.py configs/cityscapes/mask2former_beit_adapter_large_896_80k_mapillary_ss.py --shape 360 480
again.
Traceback (most recent call last): File "/home/iasl/ViT-Adapter/lib/python3.8/site-packages/mmcv/utils/registry.py", line 52, in build_from_cfg return obj_cls(**args) File "/home/iasl/ViT-Adapter/segmentation/mmseg_custom/models/backbones/beit_adapter.py", line 26, in init super().init(init_values=init_values, with_cp=with_cp, *args, **kwargs) File "/home/iasl/ViT-Adapter/segmentation/mmseg_custom/models/backbones/base/beit.py", line 344, in init self.init_weights(pretrained) File "/home/iasl/ViT-Adapter/segmentation/mmseg_custom/models/backbones/base/beit.py", line 358, in init_weights load_checkpoint(self, pretrained, strict=False, logger=logger) File "/home/iasl/ViT-Adapter/segmentation/mmcv_custom/checkpoint.py", line 338, in load_checkpoint checkpoint = _load_checkpoint(filename, map_location) File "/home/iasl/ViT-Adapter/segmentation/mmcv_custom/checkpoint.py", line 286, in _load_checkpoint raise IOError(f'{filename} is not a checkpoint file') OSError: pretrained/beit_large_patch16_224_pt22k_ft22k.pth is not a checkpoint file
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/iasl/ViT-Adapter/lib/python3.8/site-packages/mmcv/utils/registry.py", line 52, in build_from_cfg return obj_cls(**args) File "/home/iasl/ViT-Adapter/segmentation/mmseg_custom/models/segmentors/encoder_decoder_mask2former.py", line 34, in init self.backbone = builder.build_backbone(backbone) File "/home/iasl/ViT-Adapter/lib/python3.8/site-packages/mmseg/models/builder.py", line 20, in build_backbone return BACKBONES.build(cfg) File "/home/iasl/ViT-Adapter/lib/python3.8/site-packages/mmcv/utils/registry.py", line 212, in build return self.build_func(*args, **kwargs, registry=self) File "/home/iasl/ViT-Adapter/lib/python3.8/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "/home/iasl/ViT-Adapter/lib/python3.8/site-packages/mmcv/utils/registry.py", line 55, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') OSError: BEiTAdapter: pretrained/beit_large_patch16_224_pt22k_ft22k.pth is not a checkpoint file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "get_flops.py", line 98, in
Then, error like above, quite difficult to use it XD
anyway, thanks for your rapid reply :)
Have you changed the pretrained/beit_large_patch16_224_pt22k_ft22k.pth
in configs/cityscapes/mask2former_beit_adapter_large_896_80k_mapillary_ss.py
to None
?
Have you changed the
pretrained/beit_large_patch16_224_pt22k_ft22k.pth
inconfigs/cityscapes/mask2former_beit_adapter_large_896_80k_mapillary_ss.py
toNone
?
Yeah, it doesn't work. idk what is the problem now, but I'll keep try it. Thanks for your help!
I had a similar problem, but I wrote a custom model as the author wrote it, and it was registered, but he still got an error: KeyError: "MaskRCNN: 'IMViTAdapter is not in the models registry'".Even if I use "python ViT-Adapter-main/detection/get_flops.py ViT-Adapter-main/detection/mmdet_custom/models/backbones/vit_adapter.py --shape 1024 1024", he will also report an error KeyError: "MaskRCNN: 'ViTBaseline is not in the models registry'"