retinaface icon indicating copy to clipboard operation
retinaface copied to clipboard

Batching on `.extract_faces` to improve GPU utilization and throughput

Open galthran-wq opened this issue 10 months ago • 5 comments

Tickets

https://github.com/serengil/retinaface/issues/105

What has been done

With this PR, .extract_faces can accept a list of images and processed them in a batch

How to test

make lint && make test

galthran-wq avatar Feb 12 '25 14:02 galthran-wq

several problems:

  • currently input images have to be of the same size (hence resize in the test), otherwise it raises an uninformative error. maybe do the same resizing in the .extract_faces, but I am not quite sure if it would hurt performance
  • I am not yet unable to reproduce a performance improvement in colab, but here is what my local 4090 says when processing 1k images:
Batch Size: 1, Total Time: 101.9
Batch Size: 10, Total Time: 61.3
Batch Size: 20, Total Time: 59.9

I'll update on this

@serengil what do you think?

galthran-wq avatar Feb 12 '25 14:02 galthran-wq

several problems:

  • currently input images have to be of the same size (hence resize in the test), otherwise it raises an uninformative error. maybe do the same resizing in the .extract_faces, but I am not quite sure if it would hurt performance
  • I am not yet unable to reproduce a performance improvement in colab, but here is what my local 4090 says when processing 1k images:
Batch Size: 1, Total Time: 101.9
Batch Size: 10, Total Time: 61.3
Batch Size: 20, Total Time: 59.9

I'll update on this

@serengil what do you think?

IMO, batch should not be supported at all :) You should raise a ticket first to discuss this.

serengil avatar Feb 12 '25 14:02 serengil

why not if it improves performance without hurting anything else (I hope)?

galthran-wq avatar Feb 12 '25 14:02 galthran-wq

why not if it improves performance without hurting anything else (I hope)?

My personal opinion, I will not close this because of the time you spend

serengil avatar Feb 12 '25 14:02 serengil

accept a list of images and processed them in a batch

Second attempt :) https://github.com/serengil/retinaface/pull/55

ZxUkr avatar May 07 '25 13:05 ZxUkr