Skip to content

supervision-0.32.2

Latest

Choose a tag to compare

@Borda Borda released this 25 Nov 08:48
· 2 commits to develop since this release
33d3659

v0.32.2: correct YOLO classes, pose joints and VLM parsing

A patch release that fixes results which used to come out silently wrong.

  • YOLO datasets with names starting above 0 load every label under its real class.
  • ViTPose results keep each joint in its own skeleton slot, and a new num_keypoints argument fixes the skeleton size.
  • Qwen answers that used to parse to nothing now give their detections, and one unreadable Gemini box no longer fails the whole response.
  • Browser-recorded WebM videos keep their real speed.
  • Objects whose mask drops out for a frame stay put instead of jumping to the image corner.

Drop-in for most users, but a few results shift and a few malformed inputs now raise, so skim the Migration guide.

✨ Spotlights / highlights

YOLO class ids follow data.yaml

data.yaml may declare names as a dict whose keys start above 0 or skip values, such as {1: cat, 2: dog}. sv.DetectionDataset.from_yolo and sv.KeyPointsDataset.from_yolo used the label id as a list index, so labels in such a dataset loaded under the wrong class, or the load failed with an out-of-range ValueError. Ids are now mapped to the name declared for them, and loaded class_id values index classes. A label id that names does not declare, a class key repeated in names (also through a YAML merge key) and a names key declared twice raise ValueError. Saving only annotations, or only the YAML, keeps the source ids. (#2985, #3066)

# data.yaml: names: {1: cat, 2: dog}; label row: "1 0.5 0.5 0.2 0.4"
dataset = sv.DetectionDataset.from_yolo(
    images_directory_path="images",
    annotations_directory_path="labels",
    data_yaml_path="data.yaml",
)
_, _, annotations = dataset[0]
dataset.classes[annotations.class_id[0]]  # "cat"; before v0.32.2: "dog"

ViTPose joints keep their slots

Hugging Face ViTPose drops joints below its score threshold and reports the survivors in labels. sv.KeyPoints.from_transformers ignored labels and packed the remaining joints from slot 0, so one dropped joint shifted every later joint and skeleton edges connected the wrong body parts. Poses with different surviving joints failed to stack, and an empty first pose hid the poses after it. Joints now land in the slot their label names, missing ones are zero-filled, and the new keyword-only num_keypoints argument sets the full skeleton size so trailing joints stay as empty slots. A negative or repeated joint label raises ValueError instead of overwriting another joint. (#2978, #3066)

filtered = [{"keypoints": xy_16, "scores": np.ones(16), "labels": np.arange(16)}]

sv.KeyPoints.from_transformers(filtered).xy.shape  # (1, 16, 2)
sv.KeyPoints.from_transformers(filtered, num_keypoints=17).xy.shape  # (1, 17, 2)

VLM answers parse more reliably

The Qwen-2.5-VL and Qwen3-VL parsers returned no detections when text before the JSON held a bracket, such as Boxes are in [x1, y1, x2, y2] format:, when an unrelated JSON array came first, or when the detection array started with null or []. They now find the detection array wherever it sits (#3011, #3066). The Gemini 2.0, 2.5, 3.5, 3.6 and 3.7 parsers skip an item whose box_2d cannot be read as four finite coordinates and keep the valid items, instead of raising TypeError for the whole response (#3005). With a classes filter, Gemini 2.5, 3.5, 3.6 and 3.7 keep confidence when every kept item has a score, even if a filtered-out item had none (#3009). DeepSeek-VL2 rejects a non-positive resolution_wh with ValueError instead of returning mirrored or all-zero boxes (#3003).

answer = 'Boxes are in [x1, y1, x2, y2] format:\n```json\n[{"bbox_2d": [100, 200, 300, 400], "label": "cat"}]\n```'
detections = sv.Detections.from_vlm(
    sv.VLM.QWEN_2_5_VL, answer, input_wh=(1000, 1000), resolution_wh=(1000, 1000)
)
len(detections)  # 1; before v0.32.2: 0

Browser-recorded WebM keeps its real speed

MediaRecorder WebM files report their 1 kHz timebase as the frame rate, so sv.VideoInfo.from_video_path returned fps == 1000.0 and sv.process_video wrote output that played about 33x too fast. A rate above 240 fps is now checked against the first frames' timestamps; when it is more than twice their measured rate, the frame timestamps give the rate and count. The rate runs to the end of the last frame, so the OpenCV and PyAV backends report the same rate and the frame count keeps the video's duration. (#3007, #3066)

info = sv.VideoInfo.from_video_path("browser_recording.webm")
info.fps  # about 30.0 instead of 1000.0

Empty masks anchor at the box center

get_anchors_coordinates(sv.Position.CENTER_OF_MASS) returned (0, 0) for a detection whose mask had no pixels. A tracked object that lost its mask for one frame jumped to the image corner, so sv.LineZone counted a phantom crossing and the dot, label and trace annotators drew there. Empty masks now anchor at the box center, for dense masks and sv.CompactMask alike. (#2976)

detections = sv.Detections(
    xyxy=np.array([[40, 40, 60, 60]], dtype=float),
    mask=np.zeros((1, 100, 100), dtype=bool),
    class_id=np.array([0]),
)
detections.get_anchors_coordinates(sv.Position.CENTER_OF_MASS)  # [[50., 50.]]

πŸ”„ Migration guide

No breaking changes in this release, and nothing was removed or newly deprecated. The deprecations announced in v0.32.0 still target v0.35.0, and the new num_keypoints argument is optional. Deprecations from v0.30.0 are scheduled for removal in v0.33.0.

Several fixes change returned values or reject inputs that used to load silently. If you compare results across versions, check these:

  • YOLO datasets with sparse names: loaded class_id values become positions in classes, and labels resolve to their declared class. A dataset with 0-based label rows and 1-based names keys loaded before and now raises ValueError, as do repeated class keys and a names key declared twice; fix data.yaml. Re-check models trained or evaluated on such datasets. (#2985, #3066)

    # data.yaml: names: {1: cat, 2: dog}
    # label row "1 ..."
    dataset.classes[annotations.class_id[0]]  # before: "dog"   after: "cat"
    # label row "0 ..." (id not declared in names)
    sv.DetectionDataset.from_yolo(...)  # before: loads as "cat"   after: ValueError
  • YOLO export: exporting only annotations or only data.yaml from such a dataset raises ValueError if its classes changed after loading, a source data.yaml was edited, or merged datasets disagree on the mapping. Export both to write normalized ids. (#2985, #3066)

    dataset.as_yolo(annotations_directory_path="out/labels")  # after: ValueError if classes changed or sources disagree
    dataset.as_yolo(annotations_directory_path="out/labels", data_yaml_path="out/data.yaml")  # writes normalized ids
  • KeyPoints.from_transformers: ViTPose arrays can be wider than before and contain zero-filled slots, and a negative or repeated joint label raises ValueError. (#2978, #3066)

    # ViTPose results where the last joint was filtered out (16 of 17 joints kept)
    sv.KeyPoints.from_transformers(results, num_keypoints=17).xy.shape  # before: TypeError   after: (1, 17, 2)
  • CENTER_OF_MASS anchors: an empty mask anchors at its box center, and a batch containing one returns floating-point anchors. (#2976)

    # empty mask at box [40, 40, 60, 60]
    detections.get_anchors_coordinates(sv.Position.CENTER_OF_MASS)  # before: [[0, 0]]   after: [[50., 50.]]
  • Threshold 0: NMM and sv.match_detections no longer merge or match detections with zero overlap. Higher thresholds are unchanged. (#2972, #2992)

    # three disjoint boxes
    len(detections.with_nmm(threshold=0))  # before: 1 (one union box)   after: 3
  • Classifications.get_top_k: tied classes come back in input order, and NaN ranks last. (#2989)

    # confidences [0.5, 0.9, 0.9]
    classifications.get_top_k(2)[0]  # before: [2, 1]   after: [1, 2]
  • VideoInfo: fps and total_frames change for files reporting more than 240 fps whose reported rate is more than twice the measured one. (#3007)

    sv.VideoInfo.from_video_path("browser_recording.webm").fps  # before: 1000.0   after: about 30.0
  • New ValueError: a wrong-length value in KeyPoints.__setitem__ (#2974) and a non-positive resolution_wh for DeepSeek-VL2 (#3003).

    keypoints["name"] = ["a"]  # wrong length: before: stored silently   after: ValueError
    sv.Detections.from_vlm(sv.VLM.DEEPSEEK_VL_2, text, resolution_wh=(0, 100))  # before: mirrored or zero boxes   after: ValueError

πŸ“ Notable changes

πŸš€ Added

  • num_keypoints in KeyPoints.from_transformers β€” a keyword-only argument giving the full skeleton size, so joints dropped by confidence filtering stay as zero-filled slots and frames share one shape. (#2978)

πŸ”§ Fixed

  • Datasets: YOLO labels loaded under the wrong class, or failed to load, when names was a dict starting above 0 or skipping ids (#2985, #3066), and 2- and 4-bit grayscale segmentation PNGs lost their class ids (#2999).
  • Key points: ViTPose joints shifted slots after confidence filtering (#2978), joint selection misaligned per-joint covariance so VertexEllipseAnnotator, VertexEllipseOutlineAnnotator and VertexEllipseHaloAnnotator raised or drew on the wrong joints (#2979), and KeyPoints.__setitem__ stored wrong-length values silently (#2974). Covariance under data["covariance"] (supervision.config.KEYPOINT_COVARIANCE_DATA_FIELD) is now subset along the joint axis.
  • VLM parsing: Qwen answers with bracketed text, an earlier JSON array or a null first item gave no detections (#3011, #3066), one malformed Gemini box failed the whole response (#3005), a filtered-out Gemini item without a score dropped every confidence (#3009), and DeepSeek-VL2 accepted a non-positive resolution_wh (#3003).
  • Video: browser-recorded WebM reported 1000.0 fps (#3007, #3066), and process_video(preserve_audio=True) moved delayed audio to the start of the output (#2988).
  • Detection: CENTER_OF_MASS anchored empty masks at (0, 0) (#2976), NMM merged and match_detections paired non-overlapping detections at threshold 0 (#2972, #2992), and Detections.from_ncnn raised AttributeError on Python scalar coordinates (#2982).
  • Metrics: mask mAP expanded CompactMask inputs to full-image arrays (#3000), and result plots overwrote the user's Matplotlib font family (#2991).
  • Classification: get_top_k put the last tied class first and ranked NaN first (#2989).
  • Images: sv.crop_image raised cv2.error with the OpenCV backend when the box had no pixels in an RGB, RGBA or palette Pillow image (#2970).

πŸ† Contributors

Thanks to everyone who worked on this release.

  • Bahaa Mattar (@BahaaMattar) β€” made the Qwen parser find detections after bracketed text, kept valid Gemini boxes beside malformed ones and kept Gemini confidence through class filtering.
  • Burak Enes Soydan (@EnesSoydan) β€” mapped YOLO class ids to the names data.yaml declares and validated resolution_wh in the DeepSeek-VL2 parser.
  • @Viranshul-P β€” fixed the frame rate of browser-recorded WebM.
  • @ArthDubey1011 β€” stopped match_detections pairing disjoint boxes at threshold 0 and added BGRA annotator tests.
  • Pratik Kumar Dhakar (@Pratik-Kumar-Dhakar, LinkedIn) β€” added strict type checking to the remap_classes tests.
  • NIKHIL (@Nikhi00718, LinkedIn) β€” evaluated compact masks without full-image arrays and kept class ids in low-bit grayscale PNGs.
  • Mohammad Hijjawi (@MohammadHijjawi97, LinkedIn) β€” kept the user's Matplotlib font family after metric plots and fixed tie order in get_top_k.
  • Ahmet Mert Γ–zacar (@AhmetMert01, LinkedIn) β€” preserved audio timing in process_video, accepted Python scalars in from_ncnn and kept key point covariance aligned.
  • A Aswanth Raj (@aswanth-07, LinkedIn) β€” kept ViTPose joints in their slots and added num_keypoints.
  • Avanish Garg (@avanish-garg, LinkedIn) β€” stopped NMM merging non-overlapping detections at threshold 0, anchored empty masks at the box center and validated KeyPoints.__setitem__ lengths.
  • Sohail Shaikh (@sohailshk, LinkedIn) β€” returned an empty Pillow image from crop_image for a box with no pixels.
  • Jirka Borovec (@Borda, LinkedIn) β€” maintainer: package metadata, changelog, review and the pre-release hardening of Qwen parsing, YOLO mappings, video timing and ViTPose validation.

Automated contributions: @pre-commit-ci[bot]


Full changelog: 0.32.1...0.32.2

Drafted by /oss:release, an AI skill in AI Rig. If it saved you time, a ⭐ helps others find it.