facebookresearch / facebookresearch/sam2

TypeError: PromptEncoder.forward() got an unexpected keyword argument 'batch_size'

Open
#383 0 comments 0 reactions 0 assignees View on GitHub
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)`
![image](https://github.com/user-attachments/assets/e2d2aeee-49da-4b3b-82c9-1dfb6762d8fc)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.