[X] I have updated the extension to the latest version
What happened?
I faced 2 problems and here is the solution to them. Maybe these rectifications can be done in ReActor too -
FIRST
ReActor uses insightface ( a python deep learing library). Insightface uses onxruntime or onxruntime-gpu.
When you use ReActor (and onxruntime as a consequence) in a place where you have the physical GPU in some remote place, Like remote server, aws, collab etc. There is a problem - https://github.com/danielgatis/rembg/pull/529
onxruntime automatically detects the number of threads to use for parallel processing on your CPU, based on your CPU architecture. But when you use Virtual Machines or virtual systems like servers etc, There is a VM abstraction layer between onxruntime and OS kernel/CPU. And onxruntime is not able to surpass it to know the details of your CPU, and can't know how to use threading. This gives off warnings and errors for threads.
To set threads like this you have to change the insightface library itself. You can do this by Monkey patching. (ReActor does already use monkey patching in console_log_patch.py ). You will have to change the code in model_zoo.py file in insightface.
This solved my problem with thread errors.
SECOND
When a insight face gets images of different sizes, there are problems sometimes with the detection of face.
This is solved in the ReActor code by halving det_size. But this didn't help in my case.
Insightface suggests that your image shape should be divisible by 32. So do that before putting the src and target images in insightface.
For me when the det_size was equal to the img shape, there was no problem in detection of face. So make it equal in the code.
I have made all the above changes in script dir. and it works fine (12 sec for one 576x320 image face swap on gpu) so if someone faces same problem. Let me know, I'll fork,commit.
Steps to reproduce the problem
The first part of the problem only appears on VMs.
Thread error looks like this -
2023-05-18 08:24:58.694297027 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 531, index: 6, mask: {7, 39, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set.
2023-05-18 08:24:58.698247687 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 532, index: 7, mask: {8, 40, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set.
2023-05-18 08:24:58.702247091 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 533, index: 8, mask: {9, 41, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set.
First, confirm
What happened?
I faced 2 problems and here is the solution to them. Maybe these rectifications can be done in ReActor too -
FIRST
SECOND
I have made all the above changes in script dir. and it works fine (12 sec for one 576x320 image face swap on gpu) so if someone faces same problem. Let me know, I'll fork,commit.
Steps to reproduce the problem
Sysinfo
Relevant console log
Additional information
No response