Context
Our detection models are trained primarily on daytime images and are not intended to run during the night. Running inference on night images leads to a some false positives.
Current behavior
Night detection currently relies on the camera IR mode (automatic IR detection) to determine when to stop the inference loop.
This assumption does not hold for all cameras, especially third-party cameras that are not installed by Pyronear, as they may not expose or support IR information. In these cases, inference continues throughout the night, resulting in unnecessary detections.
Proposed solution
Make the night detection strategy configurable on a per-camera basis.
One possible strategy is to rely on a sunrise/sunset service using the camera coordinates to determine whether it is currently night. This was the historical implementation and may still exist in the repository (see
|
def is_day_time(cache: Optional[Path], frame: Image.Image, strategy: str, delta: int = 0) -> bool: |
)
As part of this task:
- Investigate whether the historical sunrise/sunset implementation is still present in the repository.
- Reuse it if possible; otherwise, reimplement an equivalent solution.
- Add a configurable parameter to the camera configuration to select the night detection strategy.
Example (to be discussed):
night_detection_strategy: ir
# or
night_detection_strategy: sunrise_sunset
Acceptance criteria
- A working alternative night detection strategy is available for cameras without IR support.
- The night detection strategy is configurable in the camera configuration.
- Existing IR-based behavior remains unchanged.
- Inference is not executed during night periods for cameras using the configured strategy, reducing night-time false positives.
- Automated tests are added where appropriate (the repository currently has limited test coverage, making this a good opportunity to improve it).
Context
Our detection models are trained primarily on daytime images and are not intended to run during the night. Running inference on night images leads to a some false positives.
Current behavior
Night detection currently relies on the camera IR mode (automatic IR detection) to determine when to stop the inference loop.
This assumption does not hold for all cameras, especially third-party cameras that are not installed by Pyronear, as they may not expose or support IR information. In these cases, inference continues throughout the night, resulting in unnecessary detections.
Proposed solution
Make the night detection strategy configurable on a per-camera basis.
One possible strategy is to rely on a sunrise/sunset service using the camera coordinates to determine whether it is currently night. This was the historical implementation and may still exist in the repository (see
pyro-engine/pyroengine/core.py
Line 34 in ecf3a5a
As part of this task:
Example (to be discussed):
Acceptance criteria