mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
refactor(crowd_analysis): simplify table + upgrade YOLO + add regional holidays
- Remove internal YOLO counts (cars/people/buses/total_vehicles) from crowd_analysis table - Keep only crowd_density and confidence_scores for persistence (no ML training impact) - Upgrade from YOLOv8n to YOLOv11m for better person detection (fewer false positives) - Add regional holidays: Día de Castilla y León (4/23), Santiago Apóstol (7/25, shared with Galicia) - Add Easter Monday (moveable, 2018-2035) for Castilla y León and Galicia - Update all tests to match simplified crowd_analysis schema Tests: all 38 SQLite/crowd_analyzer tests + 13 feature tests passing.
This commit is contained in:
1 parent
fa7d61b7db
commit
5e2a22340f
5 files changed
+25
-78
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"""Crowd density estimator using YOLOv8 object detection.
|
||||
"""Crowd density estimator using YOLOv11 object detection.
|
||||
|
||||
Analyses webcam snapshot images from ski stations to estimate crowd levels.
|
||||
Uses the YOLOv8 nano model (``yolov8n.pt``) from the ``ultralytics`` package
|
||||
Uses the YOLOv11 medium model (``yolov11m.pt``) from the ``ultralytics`` package
|
||||
to detect people, cars, buses and trucks.
|
||||
|
||||
Detected object counts are mapped to three crowd density levels:
|
||||
@@ -36,7 +36,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
CONFIG_PATH = BASE_DIR / "config" / "stations.yaml"
|
||||
|
||||
# YOLO model weights file – downloaded automatically on first use.
|
||||
YOLO_MODEL_WEIGHTS = "yolov8n.pt"
|
||||
YOLO_MODEL_WEIGHTS = "yolov11m.pt"
|
||||
|
||||
# COCO class names that count towards crowd estimation.
|
||||
VEHICLE_CLASSES = {"car", "bus", "truck", "motorcycle"}
|
||||
@@ -66,8 +66,8 @@ class CrowdAnalyzer:
|
||||
Path to the stations YAML configuration file. Defaults to
|
||||
``config/stations.yaml`` relative to the project root.
|
||||
model_weights:
|
||||
YOLOv8 weights identifier passed to ``ultralytics.YOLO()``.
|
||||
Defaults to ``"yolov8n.pt"`` (nano model).
|
||||
YOLOv11 weights identifier passed to ``ultralytics.YOLO()``.
|
||||
Defaults to ``"yolov11m.pt"`` (medium model).
|
||||
store:
|
||||
SQLite store where analysis results are written.
|
||||
"""
|
||||
@@ -101,10 +101,6 @@ class CrowdAnalyzer:
|
||||
dict
|
||||
Keys:
|
||||
|
||||
* ``cars_detected`` – number of cars detected
|
||||
* ``people_detected`` – number of people detected
|
||||
* ``buses_detected`` – number of buses detected
|
||||
* ``total_vehicles`` – cars + buses + trucks combined
|
||||
* ``crowd_density`` – ``"low"``, ``"medium"``, or ``"high"``
|
||||
* ``confidence_scores`` – list of per-detection confidence values
|
||||
* ``timestamp`` – ISO-8601 timestamp of when analysis ran
|
||||
@@ -153,10 +149,6 @@ class CrowdAnalyzer:
|
||||
total_vehicles = cars + buses + trucks
|
||||
|
||||
return {
|
||||
"cars_detected": cars,
|
||||
"people_detected": people,
|
||||
"buses_detected": buses,
|
||||
"total_vehicles": total_vehicles,
|
||||
"crowd_density": self._classify_density(cars, people),
|
||||
"confidence_scores": confidence_scores,
|
||||
"timestamp": datetime.now().isoformat(timespec="seconds"),
|
||||
@@ -321,10 +313,6 @@ class CrowdAnalyzer:
|
||||
return {
|
||||
"station_id": station_id,
|
||||
"image_path": image_path,
|
||||
"cars_detected": 0,
|
||||
"people_detected": 0,
|
||||
"buses_detected": 0,
|
||||
"total_vehicles": 0,
|
||||
"crowd_density": "unknown",
|
||||
"confidence_scores": [],
|
||||
"timestamp": datetime.now().isoformat(timespec="seconds"),
|
||||
|
||||
Reference in new issue
Block a user