Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USING MASK PROMPTS INSTEAD OF BOX OR POINTS #587

Open
Mukwaya-Arthur opened this issue Mar 3, 2025 · 0 comments
Open

USING MASK PROMPTS INSTEAD OF BOX OR POINTS #587

Mukwaya-Arthur opened this issue Mar 3, 2025 · 0 comments

Comments

@Mukwaya-Arthur
Copy link

I already have my grey scale images and i want to use it as an input instead of using points. how can i do that? , Here is my code block.
prompts = {}
ann_frame_idx = 0 # The frame index we interact with
ann_obj_id = 2 # Give a unique ID to each object we interact with (it can be any integer)

Add two positive clicks at (x, y) = (200, 900) and (50, 600) for the traversable road

points = np.array([[590, 500],[500,700],[250,980],[400,600]], dtype=np.float32)
labels = np.array([1,1,1,0], np.int32) # Two labels, both positive clicks
prompts[ann_obj_id] = points, labels # Store the points and labels for ann_obj_id

Add the new points or box

_, out_obj_ids, out_mask_logits = predictor.add_new_points_or_box(
inference_state=inference_state,
frame_idx=ann_frame_idx,
obj_id=ann_obj_id,
points=points,
labels=labels,
)

Show the results on the current (interacted) frame

plt.figure(figsize=(9, 6))
plt.title(f"frame {ann_frame_idx}")

Open and display the current frame image

plt.imshow(Image.open(os.path.join(video_dir, frame_names[ann_frame_idx])))

Show the input points

show_points(points, labels, plt.gca())

Iterate through output object IDs and display their prompts and masks

for i, out_obj_id in enumerate(out_obj_ids):
# Show the points corresponding to the current object
show_points(*prompts[out_obj_id], plt.gca())
# Show the mask for the current object
show_mask((out_mask_logits[i] > 0.0).cpu().numpy(), plt.gca(), obj_id=out_obj_id)..... i have attached a grey scale image

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant