-
-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batching on .extract_faces
to improve GPU utilization and throughput
#116
base: master
Are you sure you want to change the base?
Conversation
.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -117,3 +117,68 @@ def test_resize(): | |||
plt.imshow(face) | |||
plt.show() | |||
logger.info("✅ resize test done") | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -15,6 +15,31 @@ def int_tuple(t): | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Tickets
#105
What has been done
With this PR,
.extract_faces
can accept a list of images and processed them in a batchHow to test