Skip to content

TypeError: register_buffer() takes 3 positional arguments but 4 were given #2

Description

@markhanslip

Hi,

I've tried setting this up locally as per your instructions and on running transfer_any_style.py I keep hitting the following error:

Traceback (most recent call last):
  File "transfer_any_style.py", line 631, in <module>
    main(sys.argv[1:])
  File "transfer_any_style.py", line 352, in main
    sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
  File "/home/m4rk/anaconda3/envs/PyTorch/lib/python3.7/site-packages/segment_anything/build_sam.py", line 20, in build_sam_vit_h
    checkpoint=checkpoint,
  File "/home/m4rk/anaconda3/envs/PyTorch/lib/python3.7/site-packages/segment_anything/build_sam.py", line 100, in _build_sam
    pixel_std=[58.395, 57.12, 57.375],
  File "/home/m4rk/anaconda3/envs/PyTorch/lib/python3.7/site-packages/segment_anything/modeling/sam.py", line 46, in __init__
    self.register_buffer("pixel_mean", torch.Tensor(pixel_mean).view(-1, 1, 1), False)
TypeError: register_buffer() takes 3 positional arguments but 4 were given

I'm not familiar with this segment-anything library - I've tried pip install segment-anything-py (the command in your ReadME didn't work for me) which installs version 0.1 and then tried pip install git+https://github.com/facebookresearch/segment-anything.git per this HuggingFace repo which installs version 1.0, but I hit the same error both times.

Any help appreciated, thanks :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions