[英]Get error for using nms, : 'module' object is not callable
My code is:我的代码是:
keep, num_to_keep, _ = nms(proposals, scores, overlap=nms_thres, top_k=nms_topk)
And I'm getting this error:我收到此错误:
File "C:\Users\RaSoul\LaneATT\lib\models\laneatt.py", line 129, in nms
keep, num_to_keep, _ = nms(proposals, scores, overlap=nms_thres, top_k=nms_topk)
TypeError: 'module' object is not callable
I'm confused with the error, why is that?我对错误感到困惑,为什么会这样?
It seems like nms
is a function defined in nms.py
file.似乎nms
是nms.py
文件中定义的函数。
When importing nms
:导入nms
:
import nms
You import all functions in the file nms.py
into the "scope" nms
.您将文件nms.py
中的所有函数导入“范围” nms
。 Therefore, you should call the function nms
defined in nms.py
like this:因此,您应该像这样调用nms.py
定义的函数nms
:
keep, num_to_keep, _ = nms.nms(proposals, scores, overlap=nms_thres, top_k=nms_topk)
Alternatively, you can import the specific function nms
from nms.py
:或者,您可以从nms.py
导入特定函数nms
:
from nms import nms
This will put the nms
function in the global "scope" and you will not need to call it with nms.nms(...)
, but rather use simply nms(...)
.这会将nms
函数置于全局“范围”中,您无需使用nms.nms(...)
调用它,而只需使用nms(...)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.