facebookresearch / facebookresearch/segment-anything

RuntimeError: An image must be set with .set_image(...) before mask prediction.

Open
#357 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
54.9k
Forks
6.4k
PR merge metrics
No merged PRs in 30d

Description

This is a really werid bug; I'm only getting this sometimes in production.

occasionally, when I call mask_generator.generate(image) where mask_generator_2 is an instance of SamAutomaticMaskGenerator.

mask_generator_2 = SamAutomaticMaskGenerator(
    model=sam,
    points_per_side=32,
    pred_iou_thresh=0.86,
    stability_score_thresh=0.92,
    crop_n_layers=1,
    crop_n_points_downscale_factor=2,
    min_mask_region_area=100,  # Requires open-cv to run post-processing
)

def some_fn_called_from_flask(image):
   masks2_annotations = mask_generator_2.generate(image)

can this be because SamAutomaticMaskGenerator .generate is being called again while it is still generating the previous image?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at SamAutomaticMaskGenerator.generate and reproduce the reported production pattern with overlapping calls, checking whether shared state causes the missing image error. Confirm the concurrency behavior and define done as a verified fix or a clear documented explanation, with a regression test if the behavior can be reproduced.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.