pyroengine.engine

The engine module contains everything to manage the whole Fire Detection process by capturing and saving the image and by predicting whether there is a fire on this image

class pyroengine.engine.Engine(model_path: str | None = None, conf_thresh: float = 0.15, api_url: str | None = None, cam_creds: Dict[str, Dict[str, str]] | None = None, latitude: float | None = None, longitude: float | None = None, nb_consecutive_frames: int = 4, frame_size: Tuple[int, int] | None = None, cache_backup_period: int = 60, frame_saving_period: int | None = None, cache_size: int = 100, cache_folder: str = 'data/', backup_size: int = 30, jpeg_quality: int = 80, day_time_strategy: str | None = None, save_captured_frames: bool | None = False, **kwargs: Any)[source]

This implements an object to manage predictions and API interactions for wildfire alerts.

Parameters:
  • hub_repo – repository on HF Hub to load the ONNX model from

  • conf_thresh – confidence threshold to send an alert

  • api_url – url of the pyronear API

  • cam_creds – api credectials for each camera, the dictionary should be as the one in the example

  • latitude – device latitude

  • longitude – device longitude

  • alert_relaxation – number of consecutive positive detections required to send the first alert, and also the number of consecutive negative detections before stopping the alert

  • frame_size – Resize frame to frame_size before sending it to the api in order to save bandwidth (H, W)

  • cache_backup_period – number of minutes between each cache backup to disk

  • frame_saving_period – Send one frame over N to the api for our dataset

  • cache_size – maximum number of alerts to save in cache

  • day_time_strategy – strategy to define if it’s daytime

  • save_captured_frames – save all captured frames for debugging

  • kwargs – keyword args of Classifier

Examples

>>> from pyroengine import Engine
>>> cam_creds ={
>>> "cam_id_1": {'login':'log1', 'password':'pwd1'},
>>> "cam_id_2": {'login':'log2', 'password':'pwd2'},
>>> }
>>> pyroEngine = Engine(None, 0.25, 'https://api.pyronear.org', cam_creds, 48.88, 2.38)
clear_cache() None[source]

Clear local cache

predict(frame: Image, cam_id: str | None = None) float[source]

Computes the confidence that the image contains wildfire cues

Parameters:
  • frame – a PIL image

  • cam_id – the name of the camera that sent this image

Returns:

the predicted confidence

heartbeat(cam_id: str) Response[source]

Updates last ping of device