CameraTraps icon indicating copy to clipboard operation
CameraTraps copied to clipboard

Support NumPy Array Input for `batch_image_detection`

Open NetZissou opened this issue 9 months ago • 0 comments

Search before asking

  • [x] I have searched the Pytorch-Wildlife issues and found no similar bug report.

Description

Currently, batch_image_detection requires images to be stored as files on disk, which poses efficiency challenges for workflows dealing with images stored in structured data formats such as Parquet. Supporting direct NumPy array input would enable a more efficient and scalable pipeline by eliminating the need to write intermediate files.

Use case

I propose enhancing batch_image_detection to accept a list of NumPy arrays as input, enabling in-memory image processing. Since YOLO inference supports NumPy arrays as input, this should be a straightforward implementation.

We are working with a large dataset where images are stored as binary columns in structured Parquet files along with their metadata. To improve efficiency, we would like to:

  • Decode the binary images directly into NumPy arrays in memory.
  • Pass them to the detector without writing intermediate JPEG files to disk.
  • Run inference efficiently, reducing both storage and I/O overhead.

Supporting direct NumPy array input would significantly enhance workflows that involve in-memory image processing, such as those using PySpark or Dask. This feature would eliminate unnecessary disk writes and improve scalability for large-scale image detection tasks.

Would the maintainers be open to a PR for this enhancement?

Additional

No response

Are you willing to submit a PR?

  • [x] Yes I'd like to help by submitting a PR!

NetZissou avatar Mar 14 '25 21:03 NetZissou