detection
Operate Pytorch-Wildlife image detectors for camera-trap and overhead wildlife localization, including MegaDetector V5/V6, HerdNet, OWL, public variants, local weights, batching, and result interpretation.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- detection
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Operate Pytorch-Wildlife image detectors for camera-trap and overhead wildlife localization, including MegaDetector V5/V6, HerdNet, OWL, public variants, local weights, batching, and result interpretation.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md6.3 KB
- 参考文档references/model-overview.md4.1 KB
- 参考文档references/troubleshooting.md5.3 KB
- 参考文档references/workflows.md4.9 KB
- 脚本scripts/check_detection_environment.py4.2 KB
03 SKILL.md 正文
Detection
Use this skill when the request is to locate animals, people, or vehicles in
images with Pytorch-Wildlife 1.3.0. It covers camera-trap images, overhead
wildlife imagery, single-image inference, image-folder batches, local detector
weights, device choice, confidence thresholds, and the standard
supervision.Detections result contract.
Load the linked references for exact signatures, model/version tables, output caveats, and recovery steps:
Route the request
- Decide whether the imagery is ordinary camera-trap imagery or overhead/aerial imagery. Start with MegaDetector V6 for ordinary wildlife detection. Use OWL-C or OWL-T for overhead imagery and HerdNet for dense-herd localization or counting-oriented workflows.
- Select the wrapper and exact version before constructing it. V5 uses
aorb; the standard V6 wrapper accepts only the fiveMDV6-*values documented in the API reference. MIT and Apache V6 variants are separate classes. - Decide whether weights may be fetched. For offline or custom-weight work,
pass an existing local checkpoint with
weights=...and usedevice="cpu"unless the checkpoint and CUDA stack have been verified. - Pick
single_image_detectionfor one path or RGB HWC ndarray. Pickbatch_image_detectionfor an image directory; only standard Ultralytics V6/Deepfaune wrappers also accept a sequence of RGB HWC ndarrays. - Inspect
result["detections"]before post-processing. Route JSON, image annotation, crop/separation, and video output todata-and-postprocessing. Route detector-crop classification toclassification, and training or fine-tuning tofine-tuning.
Minimal public usage
from PytorchWildlife.models import detection as pw_detection
model = pw_detection.MegaDetectorV6(
device="cpu", weights="/path/to/local/model.pt",
version="MDV6-yolov10-c",
)
one = model.single_image_detection("capture.jpg", det_conf_thres=0.20)
many = model.batch_image_detection("captures/", batch_size=16,
det_conf_thres=0.20)
The path above is an input placeholder, not a required package location. Do not construct a model with default pretrained settings in a no-network run. The constructors can load weights during construction; the safe environment checker never constructs a model.
Quick selection checklist
- General camera-trap screening: standard
MegaDetectorV6. - Existing V5 workflow or checkpoint:
MegaDetectorV5. - Dense herds:
HerdNet; overhead imagery:OWLCorOWLT. - Licensing/backend-specific V6 needs: use the separate MIT or Apache wrapper.
Result contract
For the normal detector wrappers, a result is a dictionary containing an image
identifier (img_id, or an image object for some ndarray calls), a
supervision.Detections object, and formatted labels. The detections object
contains xyxy (N x 4 pixel boxes), confidence (N), and class_id (N).
MegaDetector classes map 0=animal, 1=person, and 2=vehicle; always inspect
model.CLASS_NAMES for HerdNet, OWL, or third-party wrappers because their
class maps differ. normalized_coords, when supplied, is intended to contain
[x1/W, y1/H, x2/W, y2/H]; see the API reference before trusting it across
all wrappers.
Operational guardrails
- Confidence thresholds default to
0.2and are applied at inference. Validate caller-provided values in[0, 1]; the package does not provide a universal range check. - HerdNet applies both
det_conf_thresandclf_conf_thres, using strict greater-than comparisons. OWL has only a detection threshold. - HerdNet, OWL-C, and OWL-T use patch/stitch inference and their source batch
loops effectively process the first image of each loaded batch. Use
batch_size=1for predictable operation. - RGB arrays should be HWC (
height, width, 3), not CHW. A directory batch recursively discovers common image extensions and preserves source paths. id_stripis passed to Python string.strip, so it removes matching characters at the ends rather than a path prefix.- Default pretrained constructors may access the network and cache files. Missing cache files, optional legacy imports, and CUDA availability are operational prerequisites, not detection results.
For exact constructor signatures, supported versions, coordinate caveats, custom-weight behavior, and specialized wrappers, use the references rather than inferring from this router.
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).