Skip to content

Commit

Permalink
use resize frame (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
MateoLostanlen authored Jul 2, 2024
1 parent aaf00e6 commit 040552c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pyroengine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,14 @@ def predict(self, frame: Image.Image, cam_id: Optional[str] = None) -> float:
cam_key = cam_id or "-1"
# Reduce image size to save bandwidth
if isinstance(self.frame_size, tuple):
frame_resize = frame.resize(self.frame_size[::-1], getattr(Image, "BILINEAR"))
else:
frame_resize = frame
frame = frame.resize(self.frame_size[::-1], getattr(Image, "BILINEAR"))

# Inference with ONNX
preds = self.model(frame.convert("RGB"), self.occlusion_masks[cam_key])
conf = self._update_states(frame_resize, preds, cam_key)
conf = self._update_states(frame, preds, cam_key)

if self.save_captured_frames:
self._local_backup(frame, cam_id, is_alert=False)

# Log analysis result
device_str = f"Camera '{cam_id}' - " if isinstance(cam_id, str) else ""
Expand All @@ -285,9 +286,6 @@ def predict(self, frame: Image.Image, cam_id: Optional[str] = None) -> float:
self._dump_cache()
self.last_cache_dump = ts

if self.save_captured_frames:
self._local_backup(frame_resize, cam_id, is_alert=False)

return float(conf)

def _stage_alert(self, frame: Image.Image, cam_id: str, ts: int, localization: list) -> None:
Expand Down

0 comments on commit 040552c

Please sign in to comment.