media-utils
Use supervision image, video, drawing, geometry, assets, and OpenCV-backend utility APIs.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- media-utils
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use supervision image, video, drawing, geometry, assets, and OpenCV-backend utility APIs.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/backend-compatibility.md3.8 KB
- 参考文档references/media-reference.md6.8 KB
- 参考文档references/troubleshooting.md5.9 KB
03 SKILL.md 正文
Media Utils
Use this sub-skill when a task asks for supervision image/video/file helpers,
primitive drawing, geometry objects, notebook display helpers, sample assets, or
OpenCV/fallback backend diagnosis.
Route here for
- Image helpers:
load_image_from_url,crop_image,resize_image,letterbox_image,overlay_image,tint_image,grayscale_image,get_image_resolution_wh, andImageSink. - Video helpers:
VideoInfo,VideoSink,FPSMonitor,get_video_frames_generator, andprocess_video. - Primitive drawing and colors:
draw_text,draw_rectangle,draw_polygon,draw_image,calculate_optimal_text_scale,Color, andColorPalette. - Geometry and conversion helpers:
Point,Rect,Position,get_polygon_center,cv2_to_pillow,pillow_to_cv2, andimages_to_cv2. - File, notebook, and assets utilities:
list_files_with_extensions,plot_image,plot_images_grid,ImageWindow,download_assets,ImageAssets, andVideoAssets. - OpenCV dependency migration, fallback backend warnings, video codec issues, GUI/window failures, URL/image cache behavior, and asset download problems.
Route away
- High-level detection/mask/keypoint annotators that take
sceneplusDetectionsorKeyPoints: use annotators. Detections, model adapters, detection masks, detection zones, slicers, sinks, and detection utility functions: use detection-and-zones.- Dataset layouts, annotation format conversion, and dataset iteration: use datasets.
- Keypoint containers, tracking IDs,
ByteTrack, and tracker-dependent line counting: use tracking-keypoints. - Evaluation metrics and benchmarking result interpretation: use metrics.
Start with these references
- Media reference for API groups, signatures, import paths, and common inputs/outputs.
- Backend compatibility for the OpenCV optional-backend model, fallback diagnostics, GUI notes, and webcam ownership.
- Troubleshooting for image URLs/cache, video codecs, file formats, color order, assets, and window/display failures.
- Run or read the root check_supervision_install.py helper when the task starts with an unknown environment.
Operating checklist
- Identify whether the user wants low-level media primitives or high-level
detection annotation. Route high-level visualization to
annotators. - Confirm the image type and color convention. NumPy images are OpenCV-style BGR arrays; PIL images are RGB and should be converted deliberately when crossing between APIs.
- For video, require a local file path.
supervisiondoes not own webcam capture; applications should acquire live frames themselves and pass arrays into Supervision annotators or processors. - For backend questions, remember that native OpenCV is optional. A standard
Supervision install can select the documented fallback backend, while a
compatible already-installed
cv2is used at import time. - For asset helpers, do not assume network access.
download_assets(...)downloads public sample media and verifies checksums, but generated runtime guidance should remain useful when downloads are unavailable. - Keep answers self-contained. Do not tell future agents to open or run the original repository docs, examples, tests, notebooks, scripts, or local checkout files as part of runtime operation.
Common quick checks
python -c "import supervision as sv; print(sv.__version__)"
python -c "from supervision import _cv2; print(_cv2.BACKEND_NAME)"
python scripts/check_supervision_install.py --json # run from the root of this generated skill
Use the private _cv2 import only as an installation diagnostic. Application
code should use public supervision media, drawing, and annotation APIs.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).