facebookresearch / facebookresearch/sam3

SAM3 Image Inference Found 0 Objects

Open
#443 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
11.7k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Thanks for your excellent work. I have tried the example **image inference** script and changed the text prompt for several times:

```
import torch
#################################### For Image ####################################
from PIL import Image
from sam3.model_builder import build_sam3_image_model
from sam3.model.sam3_image_processor import Sam3Processor

# Load the model
bpe_path = "./sam3/sam3/assets/bpe_simple_vocab_16e6.txt.gz"
device = "cuda" if torch.cuda.is_available() else "cpu"
checkpoint_path = "/my_pretrained/sam3/sam3.pt"
model = build_sam3_image_model(bpe_path=bpe_path, device=device, checkpoint_path=checkpoint_path)
processor = Sam3Processor(model)

# Load an image
image_path = "./sam3/assets/images/test_image.jpg"
image = Image.open(image_path).convert("RGB")

inference_state = processor.set_image(image)
# Prompt the model with text
output = processor.set_text_prompt(state=inference_state, prompt="shoe")

# Get the masks, bounding boxes, and scores
masks, boxes, scores = output["masks"], output["boxes"], output["scores"]
print(f"Detected {masks.shape[0]} instances.")
print(f"Masks' shape: {masks.shape}")
```

But the model always returns **"Found 0 Objects"**, it seems that there is no error when loading the model and inferring. The output info is as followed:
```
model_builder.py:8: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
Detected 0 instances.
Masks' shape: torch.Size([0, 1, 720, 1280])
Boxes' shape: torch.Size([0, 4])
```

Appreciate it if you could help me solve this issue!

Contributor guide

Open the contributing guide

Research direction

Run the shown image-inference script with test_image.jpg, the "shoe" prompt, and the configured checkpoint to reproduce the zero detections. Start by tracing build_sam3_image_model and Sam3Processor.set_text_prompt, then compare the inference inputs and outputs; done means identifying the cause and confirming nonzero detections or documenting a reproducible limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.