Skip to content
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

Upgrade insightface #447

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

woctezuma
Copy link

@woctezuma woctezuma commented Sep 21, 2023

The following issue arises with insightface==0.6.2 or below, including the recommended version (0.2.1).

ValueError: This ORT build has ['AzureExecutionProvider', 'CPUExecutionProvider'] enabled. Since ORT 1.9, you are required to explicitly set the providers parameter when instantiating InferenceSession. For example, onnxruntime.InferenceSession(..., providers=['AzureExecutionProvider', 'CPUExecutionProvider'], ...)

See:

This issue is fixed by upgrading to insightface==0.7 or above, but the following issue arises.

TypeError: RetinaFace.detect() got an unexpected keyword argument 'threshold'

This pull request fixes this second issue, which allows to use the latest version of insightface (0.7.3).

Fix:

@dimitrisTim
Copy link

Can confirm, fix works :)

@Mr-Nobody-dey
Copy link

Again getting the same error "RetinaFace.detect() got an unexpected keyword argument 'threshold'". Can you share your .ipynb file?

!git clone https://github.com/woctezuma/SimSwap.git
I have used insightface==0.7.3

@woctezuma
Copy link
Author

woctezuma commented Oct 1, 2023

!git clone https://github.com/woctezuma/SimSwap.git I have used insightface==0.7.3

You should use the branch which incorporates the fix.

!git clone https://github.com/woctezuma/SimSwap.git --branch upgrade-insightface --single-branch

Otherwise you get the main branch, which is an exact copy of the official SimSwap.

@Mr-Nobody-dey
Copy link

Mr-Nobody-dey commented Oct 1, 2023

Ok thank you, It works like a charm. It is 9 commits behind, will you update it?

@woctezuma
Copy link
Author

woctezuma commented Oct 2, 2023

Ok thank you, It works like a charm. It is 9 commits behind, will you update it?

I can do that, but there is no much point: only the README and the notebook were modified in the 9 commits, so no Python code.

Edit: Done this time, but the point of this branch is that the pull request could be merged in the official repository, not to maintain it whenever there is a new update in the official repository. 😛

@Mr-Nobody-dey
Copy link

ok
Thanks by the way.

@yanmingsohu
Copy link

In the latest insightface version, delete line 65 of insightface_func/face_detect_crop_multi.py:

        bboxes, kpss = self.det_model.detect(img,
                                             threshold=self.det_thresh, <---remove this LINE
                                             max_num=max_num,
                                             metric='default')

TO

        bboxes, kpss = self.det_model.detect(img,
                                             max_num=max_num,
                                             metric='default')

face_detect_crop_single.py is same.

@woctezuma
Copy link
Author

woctezuma commented Oct 11, 2023

Yes, that is partially what I did:

In the latest insightface version, delete line 65 of insightface_func/face_detect_crop_multi.py:

If you only do that, then you cannot specify the detection threshold. For instance, the default value (0.5) is used instead of 0.6.

  • 0.5 default for SCRFD:

https://github.com/deepinsight/insightface/blob/c2db41402c627cab8ea32d55da591940f2258276/python-package/insightface/model_zoo/scrfd.py#L85C1-L85C1

  • 0.6:

app = Face_detect_crop(name='antelope', root='./insightface_func/models')
app.prepare(ctx_id= 0, det_thresh=0.6, det_size=(640,640),mode=mode)


NB: antelope.zip contains a file hinting at SCRFD for detection:

  • glintr100.onnx recognition
  • scrfd_10g_bnkps.onnx detection

based on the outputs found in Colab:

find model: ./insightface_func/models/antelope/glintr100.onnx recognition
find model: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx detection

So the detection model is SCRFD.

if model.taskname not in self.models:
print('find model:', onnx_file, model.taskname)
self.models[model.taskname] = model

assert 'detection' in self.models
self.det_model = self.models['detection']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants