Fix minor issues: enum types, backup path, JS URLs, status field, timestamp docs

- CameraConfig.location now uses CameraLocation enum (Pydantic v2 coerces TOML strings)
- Wildlife classifier returns ThreatLevel enum values with correct return type annotation
- Model backup path fixed: pet_id_backup.pt instead of pet_id.backup.pt
- Dashboard submitLabel JS now posts to /pets/<sighting_id>/label matching Flask route
- Pet status API computes status field (safe/unknown) based on last-seen recency
- digest.py comment explains timestamp unit difference between tables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Aaron D. Lee
2026-04-03 13:49:20 -04:00
parent 9858738e82
commit 0b82105179
6 changed files with 24 additions and 11 deletions

View File

@@ -122,7 +122,9 @@ class PetTrainer:
epoch + 1, epochs, running_loss / len(loader), accuracy)
if self._model_output_path.exists():
backup_path = self._model_output_path.with_suffix(".backup.pt")
backup_path = self._model_output_path.with_name(
self._model_output_path.stem + "_backup.pt"
)
shutil.copy2(self._model_output_path, backup_path)
log.info("Backed up previous model to %s", backup_path)

View File

@@ -1,6 +1,7 @@
"""Wildlife threat level classification."""
from vigilar.config import WildlifeConfig
from vigilar.constants import ThreatLevel
from vigilar.detection.person import Detection
@@ -8,7 +9,7 @@ def classify_wildlife_threat(
detection: Detection,
config: WildlifeConfig,
frame_area: int,
) -> tuple[str, str]:
) -> tuple[ThreatLevel, str]:
"""Classify a wildlife detection into threat level and species.
Returns (threat_level, species_name).
@@ -18,11 +19,11 @@ def classify_wildlife_threat(
# Direct COCO class mapping first
if species in threat_map.predator:
return "PREDATOR", species
return ThreatLevel.PREDATOR, species
if species in threat_map.nuisance:
return "NUISANCE", species
return ThreatLevel.NUISANCE, species
if species in threat_map.passive:
return "PASSIVE", species
return ThreatLevel.PASSIVE, species
# Fallback to size heuristics for unknown species
_, _, w, h = detection.bbox
@@ -31,8 +32,8 @@ def classify_wildlife_threat(
heuristics = config.size_heuristics
if area_ratio < heuristics.small:
return "NUISANCE", species
return ThreatLevel.NUISANCE, species
elif area_ratio < heuristics.medium:
return "PREDATOR", species
return ThreatLevel.PREDATOR, species
else:
return "PASSIVE", species
return ThreatLevel.PASSIVE, species