Huage001 / Transfer-Any-Style

An interactive demo based on Segment-Anything for style transfer which enables different content regions apply different styles.
Apache License 2.0
95 stars 4 forks source link

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

Open markhanslip opened 1 year ago

markhanslip commented 1 year ago

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 :)

markhanslip commented 1 year ago

I thought for a second my images might be RGBA but that isn't the case, they're RGB.