Spaces:
Running on T4
Running on T4
Download baseball_batting/contracts.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 2.78 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/baseball_batting/contracts.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/baseball_batting/contracts.py
-
curl -L -o contracts.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/baseball_batting/contracts.py
2.78 kB
| """Serializable records; provenance, suitability and validation are independent.""" | |
| from dataclasses import asdict, dataclass, field | |
| from typing import Any | |
| import math | |
| import numpy as np | |
| SCHEMA_VERSION = "1.0" | |
| RTMW_CORE = { | |
| "nose": 0, "left_shoulder": 5, "right_shoulder": 6, | |
| "left_elbow": 7, "right_elbow": 8, "left_wrist": 9, "right_wrist": 10, | |
| "left_hip": 11, "right_hip": 12, "left_knee": 13, "right_knee": 14, | |
| "left_ankle": 15, "right_ankle": 16, "left_big_toe": 17, | |
| "left_small_toe": 18, "left_heel": 19, "right_big_toe": 20, | |
| "right_small_toe": 21, "right_heel": 22, | |
| } | |
| STATES = {"image_supported", "model_inferred", "manual", "propagated", | |
| "interpolated", "occluded", "unknown"} | |
| def json_safe(value: Any) -> Any: | |
| if hasattr(value, "__dataclass_fields__"): | |
| return json_safe(asdict(value)) | |
| if isinstance(value, dict): | |
| return {str(k): json_safe(v) for k, v in value.items()} | |
| if isinstance(value, (list, tuple, np.ndarray)): | |
| return [json_safe(v) for v in value] | |
| if isinstance(value, np.generic): | |
| return json_safe(value.item()) | |
| if isinstance(value, float) and not math.isfinite(value): | |
| return None | |
| return value | |
| class FrameTiming: | |
| frame_id: int | |
| pts: int | None | |
| time_base: str | None | |
| playback_s: float | None | |
| physical_s: float | None | |
| width: int | |
| height: int | |
| flags: list[str] = field(default_factory=list) | |
| class Event: | |
| event_id: str | |
| type: str | |
| state: str | |
| frame_interval: list[int] | None | |
| evidence_frames: list[int] | |
| method: str | |
| review_status: str = "not_reviewed" | |
| annotator: str | None = None | |
| playback_interval_s: list[float | None] | None = None | |
| physical_interval_s: list[float | None] | None = None | |
| notes: list[str] = field(default_factory=list) | |
| confidence_interpretation: str = "candidate evidence; no calibrated probability" | |
| class Metric: | |
| metric_id: str | |
| definition_version: str | |
| value: float | None | |
| unit: str | |
| suitability: str | |
| provenance: list[str] | |
| evidence_frames: list[int] | |
| geometry_source: str | |
| timing_source: str | |
| unavailable_reason: str | None = None | |
| event_id: str | None = None | |
| uncertainty_kind: str = "unknown" | |
| validation_status: str = "reference-validation-pending" | |
| validation_scope: str | None = None | |
| feedback_eligibility: str = "descriptive-only" | |
| sensitivity: dict | None = None | |
| class Finding: | |
| finding_id: str | |
| supporting_metric_ids: list[str] | |
| rule_id: str | |
| rule_version: str | |
| description: str | |
| evidence_frames: list[int] | |
| expert_review: str = "not_reviewed" | |
| evidence_strength: str = "descriptive observation" | |
| research_exercise: dict | None = None | |