the reasons for bad segmentation results
I try to segment the plane using prompt "plane", but got this
Is there any flaws in my implementation?
model = build_sam3_image_model()
processor = Sam3Processor(model)
segm_mask = None
# Load an image
for frame_id in candidate_frames:
image = video[:, frame_id].squeeze(0) # C H W
inference_state = processor.set_image(image)
# Prompt the model with text
output = processor.set_text_prompt(state=inference_state, prompt=prompt)
# Get the masks, bounding boxes, and scores
masks, boxes, scores = output["masks"], output["boxes"], output["scores"]
if masks is not None and len(masks) > 0:
if scores[0]>0.8:
segm_mask = masks[0].unsqueeze(0).float() # H W
masked_image = overlay_masks(image, segm_mask)
masked_image.save("saved_videos/masked_frame.png")
break
I think there's probably an issue with the image formatting, either the channel ordering or normalization might not be correct.
You could try running the pre-processing steps on your input, something like:
from torchvision.transforms import v2
image = video[:, frame_id].squeeze(0)
image = v2.functional.to_image(image).to(processor.device)
image = processor.transform(image).unsqueeze(0)
print(image.mean())
If everything is working correctly, the result should have a mean near 0. If that is working, then the other thing to check is that your input is using RGB channel ordering.
Using a prompt of 'plane' on the image you posted gives this result:
I think there's probably an issue with the image formatting, either the channel ordering or normalization might not be correct.
You could try running the pre-processing steps on your input, something like:
from torchvision.transforms import v2 image = video[:, frame_id].squeeze(0) image = v2.functional.to_image(image).to(processor.device) image = processor.transform(image).unsqueeze(0) print(image.mean()) If everything is working correctly, the result should have a mean near 0. If that is working, then the other thing to check is that your input is using RGB channel ordering.
Using a prompt of 'plane' on the image you posted gives this result:
Hi, heyoeyo, please could you solve that kind? https://github.com/facebookresearch/sam3/issues/501