SysCV / sam-hq

Segment Anything in High Quality [NeurIPS 2023]
https://arxiv.org/abs/2306.01567
Apache License 2.0
3.52k stars 209 forks source link

ImportError: cannot import name 'FrozenBatchNorm2d' from 'torchvision.ops' #90

Open Guangpengwgp1202 opened 8 months ago

Guangpengwgp1202 commented 8 months ago

Hello, I followed the readme environment example in windows11conda and the following error occurred.

(sam_hq) C:\Users\Guangpeng\Desktop\model_test\sam-hq>python Python 3.8.18 | packaged by conda-forge | (default, Oct 10 2023, 15:37:54) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

from segment_anything import SamPredictor, sam_model_registry Traceback (most recent call last): File "", line 1, in File "C:\Users\Guangpeng\Desktop\model_test\sam-hq\segment_anything__init.py", line 7, in from .build_sam import ( File "C:\Users\Guangpeng\Desktop\model_test\sam-hq\segment_anything\build_sam.py", line 11, in from .modeling import ImageEncoderViT, MaskDecoderHQ, PromptEncoder, Sam, TwoWayTransformer, TinyViT File "C:\Users\Guangpeng\Desktop\model_test\sam-hq\segment_anything\modeling__init__.py", line 13, in from .tiny_vit_sam import TinyViT File "C:\Users\Guangpeng\Desktop\model_test\sam-hq\segment_anything\modeling\tiny_vit_sam.py", line 15, in from timm.models.layers import DropPath as TimmDropPath,\ File "C:\Users\Guangpeng\anaconda3\envs\sam_hq\lib\site-packages\timm__init__.py", line 2, in from .layers import is_scriptable, is_exportable, set_scriptable, set_exportable File "C:\Users\Guangpeng\anaconda3\envs\sam_hq\lib\site-packages\timm\layers\init.py", line 7, in from .classifier import ClassifierHead, create_classifier, NormMlpClassifierHead File "C:\Users\Guangpeng\anaconda3\envs\sam_hq\lib\site-packages\timm\layers\classifier.py", line 15, in from .create_norm import get_norm_layer File "C:\Users\Guangpeng\anaconda3\envs\sam_hq\lib\site-packages\timm\layers\create_norm.py", line 14, in from torchvision.ops import FrozenBatchNorm2d ImportError: cannot import name 'FrozenBatchNorm2d' from 'torchvision.ops' (C:\Users\Guangpeng\anaconda3\envs\sam_hq\lib\site-packages\torchvision\ops\init__.py)

Guangpengwgp1202 commented 8 months ago

Looking forward to your reply and thank you for contributing such an excellent project

Guangpengwgp1202 commented 8 months ago

I have solved the problem, thanks again for the excellent project

‘’conda update pytorch torchvision -c pytorch‘’