Batching on .extract_faces to improve GPU utilization and throughput#116
Batching on .extract_faces to improve GPU utilization and throughput#116galthran-wq wants to merge 7 commits intoserengil:masterfrom
.extract_faces to improve GPU utilization and throughput#116Conversation
.extract_faces to improve GPU utilization.extract_faces to improve GPU utilization and throughput
|
several problems:
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. |
|
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 |
|
|
||
| def test_batch_resize(): | ||
| img_path = "tests/dataset/img11.jpg" | ||
| faces = RetinaFace.extract_faces(img_path=[img_path, img_path], target_size=(224, 224)) |
There was a problem hiding this comment.
would you please run this test for 2 images where 1st one has 1 face and 2nd one has many faces.
i want to see result is size of 2 in this case, and 2nd item of that list is having many items.
you can add this image to dataset folder and use it.
| plt.imshow(face) | ||
| plt.show() | ||
| logger.info("✅ resize test done") | ||
|
|
There was a problem hiding this comment.
do you mind to add tests for detect_faces also? at least its return type for single item and many items.
tests/test_actions.py
Outdated
| return tuple(int(x) for x in t) | ||
|
|
||
|
|
||
| def resize_images(img_paths: list[str]) -> list[np.ndarray]: |
There was a problem hiding this comment.
this is the key thing to make batching work. It is required to be able to concat images' tensors. It will not currently work it we do not call this function beforehand.
basically, it adds black strips to each image to be max width and max height of the batch (therefore all of the same size)
ideally, I think, we'd like for this operation to happen behind the scenes on .extract_faces and the results (facial area, eyes, nose) be accordingly transformed after prediction in accordance with the original image.
Second attempt :) |
Tickets
#105
What has been done
With this PR,
.extract_facescan accept a list of images and processed them in a batchHow to test