DeOP icon indicating copy to clipboard operation
DeOP copied to clipboard

ImportError: cannot import name 'sam_model_registry_feature' from 'segment_anything'

Open Luca-Wiehe opened this issue 1 year ago • 1 comments

I've been trying to run your demo.py script. Unfortunately, I am encountering the following error message:

(deop) ~/<path>/deop$ python3 demo.py --input dataset/test/000000000285.jpg --output ./output --class-names bear other
Traceback (most recent call last):
  File "demo.py", line 20, in <module>
    from mask_former import  add_mask_former_config
  File "~/<path>/deop/mask_former/__init__.py", line 9, in <module>
    from .zero_shot_clipfeat_upsample_nodecoder_sammask_noAssembly import ZeroShotClipfeatUpsampleNodecoderSAMMaskNoAssembly
  File "~/<path>/deop/mask_former/zero_shot_clipfeat_upsample_nodecoder_sammask_noAssembly.py", line 34, in <module>
    from segment_anything import SamAutomaticMaskGenerator,sam_model_registry,  sam_model_registry_feature, SamAutomaticMaskGeneratorMaskFeature
ImportError: cannot import name 'sam_model_registry_feature' from 'segment_anything' (~/<path>/deop/segment-anything/segment_anything/__init__.py)

Note that I have manually installed the Segment Anything repository from source (according to setup instructions from their github).

Luca-Wiehe avatar Jun 17 '24 06:06 Luca-Wiehe

I've been trying to run your demo.py script. Unfortunately, I am encountering the following error message:

(deop) ~/<path>/deop$ python3 demo.py --input dataset/test/000000000285.jpg --output ./output --class-names bear other
Traceback (most recent call last):
  File "demo.py", line 20, in <module>
    from mask_former import  add_mask_former_config
  File "~/<path>/deop/mask_former/__init__.py", line 9, in <module>
    from .zero_shot_clipfeat_upsample_nodecoder_sammask_noAssembly import ZeroShotClipfeatUpsampleNodecoderSAMMaskNoAssembly
  File "~/<path>/deop/mask_former/zero_shot_clipfeat_upsample_nodecoder_sammask_noAssembly.py", line 34, in <module>
    from segment_anything import SamAutomaticMaskGenerator,sam_model_registry,  sam_model_registry_feature, SamAutomaticMaskGeneratorMaskFeature
ImportError: cannot import name 'sam_model_registry_feature' from 'segment_anything' (~/<path>/deop/segment-anything/segment_anything/__init__.py)

Note that I have manually installed the Segment Anything repository from source (according to setup instructions from their github).

I modify some code of the segment-anything to get the mask. You can install the 'segment-anything' by this reposity sam-mask

CongHan0808 avatar Jun 20 '24 06:06 CongHan0808