解决:TypeError: z_(): incompatible function arguments. The following argument types are supported
文章目录
背景
在使用之前的代码通过Dlib进行人脸识别时,报错:
Traceback (most recent call last):
File “FaceRecognizeHaarCascade copy.py”, line 13, in
return g.op(‘plugin’, g, arg0, arg1, arg2)
TypeError: call(): incompatible function arguments. The following argument types are supported:
1. (self: _dlib_pybind11.fhog_object_detector, image: array, upsample_num_times: int=0) -> _dlib_pybind11.rectangles
Invoked with: <_dlib_pybind11.fhog_object_detector object at 0x000002428AC9B030>, None, 1
报错问题
Traceback (most recent call last):
File "FaceRecognizeHaarCascade copy.py", line 13, in <module>
return g.op('plugin', g, arg0, arg1, arg2)
TypeError: __call__(): incompatible function arguments. The following argument types are supported:
1. (self: _dlib_pybind11.fhog_object_detector, image: array, upsample_num_times: int=0) -> _dlib_pybind11.rectangles
Invoked with: <_dlib_pybind11.fhog_object_detector object at 0x000002428AC9B030>, None, 1
报错翻译
主要报错信息内容翻译如下所示:
Traceback (most recent call last):
File "FaceRecognizeHaarCascade copy.py", line 13, in <module>
return g.op('plugin', g, arg0, arg1, arg2)
TypeError: __call__(): incompatible function arguments. The following argument types are supported:
1. (self: _dlib_pybind11.fhog_object_detector, image: array, upsample_num_times: int=0) -> _dlib_pybind11.rectangles
Invoked with: <_dlib_pybind11.fhog_object_detector object at 0x000002428AC9B030>, None, 1
翻译:
回溯(最近一次调用最后一次):
文件“FaceRecognizeHaarCascade copy.py”,第 13 行,在<module>
return g.op('plugin', g, arg0, arg1, arg2)
TypeError:__call__():不兼容的函数参数。支持以下参数类型:
1.(self:_dlib_pybind11.fhog_object_detector,image:array,upsample_num_times:int=0)-> _dlib_pybind11.rectangles
调用方式:<_dlib_pybind11.fhog_object_detector 对象位于 0x000002428AC9B030>、无、1
报错位置代码
...
return g.op('plugin', g, arg0, arg1, arg2)
...
报错原因
经过查阅资料,发现是给的参数不是严格匹配函数需要的输入的,这种需要具体情况具体分析,但是主要办法就是好好检查自己的代码,函数输入哪里会存在不匹配的地方。
小伙伴们按下面的解决方法即可解决!!!
解决方法
要解决这个错误,需要检查自己的代码,更正函数输入参数里存在的不匹配的地方即可,如修改参数个数或者参数类型等不匹配。
以我下面的代码为例,注册 Pytorch plugin
算子时:
//修改前
def symbolic_plugin(g, arg0, arg1, arg2):
return g.op('plugin', g, arg0, arg1, arg2)
上面的代码可能之前某些情况下确实可以正常运行,但是随着代码更新或者接口调用不同就会遇到上面的问题,主要是 g.op
函数的参数多了一个 g
:
//修改后
def symbolic_plugin(g, arg0, arg1, arg2):
return g.op('plugin', arg0, arg1, arg2)