insightface icon indicating copy to clipboard operation
insightface copied to clipboard

AssertionError:assert 'detection' in self.models

Open cai-cong opened this issue 4 years ago • 34 comments

I want to extract 512-D Feature Embedding. I download the pretrained model and run the /insightface/deploy/test.py, but image what should I do?

cai-cong avatar May 18 '21 10:05 cai-cong

https://github.com/deepinsight/insightface/blob/master/python-package/README.md

Starting from insightface>=0.2, we use onnxruntime as inference backend, please download our antelope model release from onedrive, and put it under ~/.insightface/models/, so there're onnx models at ~/.insightface/models/antelope/*.onnx.

007gzs avatar May 18 '21 11:05 007gzs

Please update insightface to >=0.2, see readme at https://github.com/deepinsight/insightface/tree/master/python-package

nttstar avatar May 18 '21 11:05 nttstar

I have downloaded the antelope and put it under ~/.insightface/models/. And my insightface version is 0.2.1 (0.2.0 version.I tried, too). But the same error is displayed.

image According to the prompt, I think this line is wrong.

cai-cong avatar May 18 '21 11:05 cai-cong

Please confirm that the file ~/.insightface/models/antelope/scrfd_10g_bnkps.onnx exists

007gzs avatar May 18 '21 11:05 007gzs

Path is ~/.insightface not insightface workspace. You can try app = FaceAnalysis(name="antelope", root=insightface_workspace_path)

007gzs avatar May 18 '21 11:05 007gzs

It's Ok. Thank you very much.

cai-cong avatar May 18 '21 11:05 cai-cong

model = insightface.model_zoo.ArcFaceONNX(model_file = xxx)

nttstar avatar May 19 '21 08:05 nttstar

image My image size is (147,117,3)

cai-cong avatar May 19 '21 09:05 cai-cong

where's your last post?

nttstar avatar May 19 '21 09:05 nttstar

image My image size is (147,117,3)

This is my last post. My code is image

cai-cong avatar May 19 '21 09:05 cai-cong

detect and face_align first

007gzs avatar May 19 '21 09:05 007gzs

I just want to extract Feature Embedding. I have extracted face, don't need to detect and face_align.

cai-cong avatar May 19 '21 09:05 cai-cong

in arcface, face image size mast 112x112

007gzs avatar May 19 '21 09:05 007gzs

how did u correct this

nadaboulares avatar May 22 '21 10:05 nadaboulares

help plz

nadaboulares avatar May 22 '21 11:05 nadaboulares

i also had the same problem when running the executable. Error displayed: Exception has occurred: AssertionError exception: no description File "E:\DataTraining\insightface-master\insightface-master\deploy\test.py", line 16, in app = FaceAnalysis(name='antelope')

i have followed the suggestions above but its still not fixed, what should i do? thanks

nhatduy19599 avatar Jun 14 '21 08:06 nhatduy19599

you can change your root directory. I don't know if the path like '~/.insightface' can work well on windows os.

nttstar avatar Jun 14 '21 11:06 nttstar

you can change your root directory. I don't know if the path like '~/.insightface' can work well on windows os.


I've tried it but still can't fix that error. "antelope" still exists in models but I still don't know why it doesn't work. When running terminal with command :python test.py the results give: E:\DataTraining\insightface-master\insightface-master\deploy> python test.py Traceback (most recent call last): File "test.py", line 22, print app = FaceAnalysis('antelope') File "C:\Users\nhatd\AppData\Local\Programs\Python\Python36\lib\site-packages\insightface\app\face_analysis.py", line 51, print init assert 'detection' in self.models AssertionError

I have tried many ways like changing face_analyst.py file in python36 and also face_analyst.py in python-package belonging to source ROOT $insightface but the result is not very satisfactor

nhatduy19599 avatar Jun 21 '21 09:06 nhatduy19599

On Windows, replace the root parameter in the FaceAnalysis Class with the complete or absolute path to the insightface folder. remember to create a model folder and place the **onnx model ** in it.

e.g root=r'C:\Users\OneDrive\Desktop\insight\insightface\Lib\site-packages\insightface'

onnx model path will be .

r'C:\Users\OneDrive\Desktop\insight\insightface\Lib\site-packages\insightface\model\antelope\*.onnx

okoliechykwuka avatar Mar 03 '22 03:03 okoliechykwuka

我说一下我的解决方法给各位参考,我发现comfyui在安装该插件时,在https://github.com/deepinsight/insightface/releases/download/v0.7/antelopev2.zip处下载了文件到“D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\”这个目录下,然后进行解压安装,解压后的路径是“D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2\antelopev2\”,然后我将这个路径下的文件全部剪切到了“D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2\”这里,然后重启就正常了。说明在软件进行解压时,多了一层目录导致。

I'd like to share my solution for your reference. I noticed that when installing the plugin in ComfyUI, it downloaded a file from https://github.com/deepinsight/insightface/releases/download/v0.7/antelopev2.zip to the directory "D:\AITools\ComfyUI-aki-v1.4\models\insightface\models" and then proceeded with the extraction and installation. After extraction, the path was "D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2\antelopev2". Then, I cut all the files from this path and pasted them into "D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2". After restarting, it worked normally. This indicates that during the software's extraction process, an extra directory layer was created, causing the issue.

ychess avatar Sep 16 '24 03:09 ychess

我说一下我的解决方法给各位参考,我发现comfyui在安装该插件时,在 https://github.com/deepinsight/insightface/releases/download/v0.7/antelopev2.zip 处下载了文件到 D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\ 这个目录下,然后进行解压安装,解压后的路径是 D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2\antelopev2\,然后我将这个路径下的文件全部剪切到了 D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2\ 这里,然后重启就正常了。说明在软件进行解压时,多了一层目录导致。

I'd like to share my solution for your reference. I noticed that when installing the plugin in ComfyUI, it downloaded a file from https://github.com/deepinsight/insightface/releases/download/v0.7/antelopev2.zip to the directory D:\AITools\ComfyUI-aki-v1.4\models\insightface\models and then proceeded with the extraction and installation. After extraction, the path was D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2\antelopev2. Then, I cut all the files from this path and pasted them into D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2. After restarting, it worked normally. This indicates that during the software's extraction process, an extra directory layer was created, causing the issue.

is work for me

mrhan1993 avatar Sep 17 '24 11:09 mrhan1993

@ychess thank for help, i face this issue just now, your solution is helpful

Prompt executed in 0.01 seconds got prompt !!! Exception during processing !!! Traceback (most recent call last): File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 323, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 198, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 169, in _map_node_over_list process_inputs(input_dict, i) File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 158, in process_inputs results.append(getattr(obj, func)(**inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_InstantID\InstantID.py", line 217, in load_insight_face model = FaceAnalysis(name="antelopev2", root=INSIGHTFACE_DIR, providers=[provider + 'ExecutionProvider',]) # alternative to buffalo_l ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface\app\face_analysis.py", line 43, in init assert 'detection' in self.models ^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError Prompt executed in 0.01 seconds got prompt !!! Exception during processing !!! Traceback (most recent call last): File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 323, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 198, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 169, in _map_node_over_list process_inputs(input_dict, i) File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 158, in process_inputs results.append(getattr(obj, func)(**inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_InstantID\InstantID.py", line 217, in load_insight_face model = FaceAnalysis(name="antelopev2", root=INSIGHTFACE_DIR, providers=[provider + 'ExecutionProvider',]) # alternative to buffalo_l ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\user\Music\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface\app\face_analysis.py", line 43, in init assert 'detection' in self.models ^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError

Leonel0727 avatar Sep 18 '24 09:09 Leonel0727

I solved this problem, comfyui automatically downloaded and put the .onnx inside antelopev2/antelopev2/.onnx. Move the onnx files into the parent folder: antelopev2/*.onnx

aminesoulaymani avatar Oct 05 '24 11:10 aminesoulaymani

On my windows system, altough files have been downloaded, it does not find them, since it does not look in the right folder

in face_analysis.py file, replace

onnx_files = glob.glob(osp.join(self.model_dir, '*.onnx'))

with onnx_files = [osp.join(dirpath, f) for dirpath, dirnames, files in os.walk(self.model_dir) for f in fnmatch.filter(files, '*.onnx')]

and add at the file beginning: import os import fnmatch

sancelot avatar Nov 25 '24 20:11 sancelot

When you first run code you have download onnx models

app = FaceAnalysis(name='antelopev2', root=".\onnx_models", providers=['CUDAExecutionProvider', 'CPUExecutionProvider'], allowed_modules=['detection'])

but model download as image if you would run project more then 2 time change antelopev2 to antelopev2/antelopev2

app = FaceAnalysis(name='antelopev2/antelopev2', root=".\onnx_models", providers=['CUDAExecutionProvider', 'CPUExecutionProvider'], allowed_modules=['detection'])

This problem is related to unpacking the zip archive

MATEMATNKx avatar Dec 01 '24 21:12 MATEMATNKx

I changed model to buffalo_l and the error is gone.

CaledoniaProject avatar Jan 28 '25 06:01 CaledoniaProject

I solved this problem, comfyui automatically downloaded and put the .onnx inside antelopev2/antelopev2/.onnx. Move the onnx files into the parent folder: antelopev2/*.onnx

can't believe after all these years no one fix it

liuziangexit avatar Feb 17 '25 14:02 liuziangexit

I solved this problem, comfyui automatically downloaded and put the .onnx inside antelopev2/antelopev2/.onnx. Move the onnx files into the parent folder: antelopev2/*.onnx

can't believe after all these years no one fix it

this is a default file unzipping issue. The code may have been tested on Linux/macos, but not on windows

Fixing the code helps to fix the error https://github.com/deepinsight/insightface/issues/2702

MATEMATNKx avatar Feb 18 '25 09:02 MATEMATNKx

I solved this problem, comfyui automatically downloaded and put the .onnx inside antelopev2/antelopev2/.onnx. Move the onnx files into the parent folder: antelopev2/*.onnx

can't believe after all these years no one fix it

this is a default file unzipping issue. The code may have been tested on Linux/macos, but not on windows

Fixing the code helps to fix the error #2702

thanks for quick reply and thank you for all you did, but what i mean is I can't believe they haven't merged fixes like yours after all these years----this issue was opened back in 2021. and btw in fact it's not a Windows-only issue, i encountered this on my mac, and i assume we can also have this on linux.

liuziangexit avatar Feb 19 '25 06:02 liuziangexit

我说一下我的解决方法给各位参考,我发现comfyui在安装该插件时,在https://github.com/deepinsight/insightface/releases/download/v0.7/antelopev2.zip处下载了文件到“D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\”这个目录下,然后进行解压安装,解压后的路径是“D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2\antelopev2\”,然后我将这个路径下的文件全部剪切到了“D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2\”这里,然后重启就正常了。说明在软件进行解压时,多了一层目录导致。

I'd like to share my solution for your reference. I noticed that when installing the plugin in ComfyUI, it downloaded a file from https://github.com/deepinsight/insightface/releases/download/v0.7/antelopev2.zip to the directory "D:\AITools\ComfyUI-aki-v1.4\models\insightface\models" and then proceeded with the extraction and installation. After extraction, the path was "D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2\antelopev2". Then, I cut all the files from this path and pasted them into "D:\AITools\ComfyUI-aki-v1.4\models\insightface\models\antelopev2". After restarting, it worked normally. This indicates that during the software's extraction process, an extra directory layer was created, causing the issue.

very good! Thx!

CoderSuHang avatar Mar 29 '25 02:03 CoderSuHang