Upgrade insightface #447

Open
woctezuma wants to merge 4 commits from woctezuma/upgrade-insightface into main
woctezuma commented 2023-09-21 11:34:47 +02:00 (Migrated from github.com)

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:

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: - #445 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: - #139 - #407
dimitrisTim commented 2023-09-24 22:32:34 +02:00 (Migrated from github.com)

Can confirm, fix works :)

Can confirm, fix works :)
Mr-Nobody-dey commented 2023-10-01 09:07:27 +02:00 (Migrated from github.com)

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

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 commented 2023-10-01 10:46:49 +02:00 (Migrated from github.com)

!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.

> !git clone https://github.com/woctezuma/SimSwap.git I have used insightface==0.7.3 You should **use the branch which incorporates the fix**. ```bash !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 commented 2023-10-01 21:49:39 +02:00 (Migrated from github.com)

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

Ok thank you, It works like a charm. It is 9 commits behind, will you update it?
woctezuma commented 2023-10-02 11:29:57 +02:00 (Migrated from github.com)

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. 😛

> 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 commented 2023-10-03 16:14:49 +02:00 (Migrated from github.com)

ok
Thanks by the way.

ok Thanks by the way.
yanmingsohu commented 2023-10-11 04:01:44 +02:00 (Migrated from github.com)

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.

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 commented 2023-10-11 18:19:58 +02:00 (Migrated from github.com)

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:

c2db41402c/python-package/insightface/model_zoo/scrfd.py (L85C1-L85C1)

  • 0.6:

a5f6dea673/test_wholeimage_swapsingle.py (L55-L56)


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.

a5f6dea673/insightface_func/face_detect_crop_single.py (L41-L43)

a5f6dea673/insightface_func/face_detect_crop_single.py (L47-L48)

Yes, that is **partially** what I did: - https://github.com/neuralchen/SimSwap/pull/447/files > 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: https://github.com/neuralchen/SimSwap/blob/a5f6dea67398eec9ee71e156f7ad15dbd7ce4977/test_wholeimage_swapsingle.py#L55-L56 --- NB: `antelope.zip` contains a file hinting at [SCRFD](https://github.com/deepinsight/insightface/tree/master/model_zoo#22-scrfd) for detection: - `glintr100.onnx` **recognition** - `scrfd_10g_bnkps.onnx` **detection** based on the outputs found in [Colab](https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/SimSwap%20colab.ipynb): ``` 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. https://github.com/neuralchen/SimSwap/blob/a5f6dea67398eec9ee71e156f7ad15dbd7ce4977/insightface_func/face_detect_crop_single.py#L41-L43 https://github.com/neuralchen/SimSwap/blob/a5f6dea67398eec9ee71e156f7ad15dbd7ce4977/insightface_func/face_detect_crop_single.py#L47-L48
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin woctezuma/upgrade-insightface:woctezuma/upgrade-insightface
git checkout woctezuma/upgrade-insightface
Sign in to join this conversation.