facebookresearch / facebookresearch/sam2
TypeError: PromptEncoder.forward() got an unexpected keyword argument 'batch_size'
- Dominant language
- Jupyter Notebook
- Stars
- 19.9k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
I’m using SAM 2.1 and the provided config to build a model, but I encountered an issue with the PromptEncoder. Specifically, when calling the forward() function, I get the following error:
`TypeError: PromptEncoder.forward() got an unexpected keyword argument 'batch_size'`
Could you provide some guidance on resolving this issue?
Thanks in advance!
code:
`sam_config = "sam2.1_hiera_s"
sam_ckpt = "./checkpoints/sam2.1_hiera_small.pt"
checkpoint = torch.load(sam_ckpt)
print(checkpoint.keys())
net = build_sam2(sam_config, sam_ckpt, device="cuda")
B = 8 # 示例 batch_size
se, de = net.sam_prompt_encoder(
points=None,
boxes=None,
masks=None,
#batch_size=B, # 确保传递 batch_size 参数
)
print(se.shape, de.shape)`

Contributor guide
Assessment
This issue has not been assessed yet.