计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
prompted-segmentation【效率与协作】Use SAM's SamPredictor for prompt-based masks from points, labels, boxes, iterative low-res mask refinement, image embeddings, and CPU/GPU checkpoint setup.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the user wants Segment Anything (SAM) masks for a specific object or region using prompts such as foreground/background points, boxes, prior masks, or repeated prompts on the same image.
SamPredictor.set_image(...) followed by repeated predict(...) calls.low_res_masks slice back as mask_input.get_image_embedding(); route ONNX export and browser runtime work to ../onnx-and-browser/.For full-image proposal generation without prompts, use ../automatic-mask-generation/ instead.
default, vit_h, vit_l, or vit_b, and pass the matching user-provided checkpoint path to sam_model_registry[model_type](checkpoint=...).sam.to(device=device).predictor = SamPredictor(sam) and call predictor.set_image(image, image_format="RGB") once per image.Nx2 (x, y), point labels as length N with 1 foreground and 0 background, and boxes as XYXY.multimask_output=True for ambiguous single-click prompts; use False for boxes or multiple prompts when one mask is desired.(masks, scores, low_res_masks), where masks is CxHxW, scores is length C, and low_res_masks is Cx256x256 logits for refinement.Sam batch notes: references/api-reference.md.references/workflows.md.references/troubleshooting.md.scripts/predictor_prompt_template.py.import numpy as np
import torch
from segment_anything import SamPredictor, sam_model_registry
model_type = "vit_b"
device = "cuda" if torch.cuda.is_available() else "cpu"
sam = sam_model_registry[model_type](checkpoint="/path/to/sam_vit_b.pth")
sam.to(device=device)
predictor = SamPredictor(sam)
predictor.set_image(image_rgb_uint8_hwc, image_format="RGB")
point_coords = np.array([[500, 375]], dtype=np.float32)
point_labels = np.array([1], dtype=np.int32)
masks, scores, low_res_masks = predictor.predict(
point_coords=point_coords,
point_labels=point_labels,
multimask_output=True,
)
best_mask = masks[int(np.argmax(scores))]