docs: model card — overview + usage (load model.zip, predict_sequence)
Browse files123---license: apache-2.0---12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697---license: apache-2.0library_name: pytorchtags:- wildfire- smoke-detection- object-detection- temporal---# Temporal Smoke Model (bbox-tube-temporal)A temporal wildfire-**smoke** classifier for short sequences of camera frames. AYOLO detector proposes boxes, boxes are linked across frames into temporal**tubes**, each tube's image patches are classified by a DINOv2 ViT + transformerhead, and a logistic calibrator turns the tube logits into a calibratedprobability and a keep/discard decision.This repo ships a single self-contained **`model.zip`**, versioned by HuggingFacerevision/tag (`v<version>`). Each release bundles everything needed to run:| file | purpose ||---|---|| `manifest.yaml` | version + provenance (train git SHA, backbone, detector) || `yolo_weights.pt` | the companion YOLO detector || `classifier.ckpt` | the temporal ViT classifier || `config.yaml` | inference + decision config || `logistic_calibrator.json` | the calibrated decision head |The model runs YOLO **itself** — you pass only raw frames, no detections.## UsageInstall the inference package (`temporal_model.core`):```bashpip install "git+https://github.com/pyronear/temporal-model.git#subdirectory=core"```Download a versioned `model.zip` and run it on a **temporally ordered** sequenceof frames:```pythonfrom pathlib import Pathfrom huggingface_hub import hf_hub_downloadfrom temporal_model.core.model import BboxTubeTemporalModel# 1. Download a specific release (pin the revision).model_zip = hf_hub_download("pyronear/temporal-model", "model.zip", revision="v0.1.0")# 2. Temporally-ordered frames. Filenames carry timestamps# (<prefix>_<YYYY-MM-DDTHH-MM-SS>.jpg); the order is the time order.frame_paths = sorted(Path("my_sequence").glob("*.jpg"))# 3. Load (device=None → auto cuda → mps → cpu) and predict.# hf_hub_download returns a str, so wrap it in Path().model = BboxTubeTemporalModel.from_package(Path(model_zip), device=None)out = model.predict_sequence(frame_paths)print("is_smoke: ", out.is_positive)print("trigger_frame_index:", out.trigger_frame_index) # 0-based; None if no smoke# Per-tube breakdown (logits, calibrated probabilities, bboxes, decision).kept = out.details.get("tubes", {}).get("kept", [])print("kept tubes: ", len(kept))````predict_sequence(frame_paths)` returns a `TemporalModelOutput`:- `is_positive: bool` — the smoke verdict.- `trigger_frame_index: int | None` — 0-based frame where smoke first crosses thedecision threshold (time-to-detection, in frames; `None` when no smoke).- `details: dict` — per-tube logits, calibrated probabilities, bboxes, and thedecision (`aggregation`, `threshold`, trigger tube).## Served API (Docker)The same model is also served as a FastAPI image with the `model.zip` baked in(auto-uses the GPU with `--gpus all`):```bashdocker run --gpus all -p 8000:8000 \-e TEMPORAL_API_S3_BUCKET=<frames-bucket> \-e TEMPORAL_API_S3_ENDPOINT_URL=<s3-endpoint> \pyronear/temporal-model-api:0.1.0# POST /predict {"frames": ["<s3-key>", ...]} GET /health```## ProvenanceEvery `model.zip` manifest records how it was built — the training git SHA, theclassifier backbone (`vit_small_patch14_dinov2.lvd142m`), and the exact companiondetector (e.g. `pyronear/yolo11s_nimble-narwhal_v6.0.0`, verified by SHA-256). Soa served model always traces back to its detector + training code.Source & pipeline: <https://github.com/pyronear/temporal-model>
README.md+94