名称 'MTCNN' 未在 python 中的 mtcnn 中定义
name 'MTCNN' is not defined in mtcnn in python
我安装了mtcnn包,可以看到:
# confirm mtcnn was installed correctly
import mtcnn
# print version
print(mtcnn.__version__)
结果:
0.0.9
然后我使用以下内容:
# prepare model
model = MTCNN()
# detect face in the image
faces = model.detect_faces(pixels)
# extract details of the face
x1, y1, width, height = faces[0]['box']
结果:
1 # prepare model
----> 2 model = MTCNN()
3 # detect face in the image
4 faces = model.detect_faces(pixels)
5 # extract details of the face
NameError: name 'MTCNN' is not defined
文档是一个很好的起点:https://github.com/ipazc/mtcnn
from mtcnn.mtcnn import MTCNN
import cv2
model = MTCNN()
有时人们所做的是将他们正在处理的文件命名为 mtcnn.py,这会导致此错误。将文件名 mtcnn.py 更改为其他名称即可。
我安装了mtcnn包,可以看到:
# confirm mtcnn was installed correctly
import mtcnn
# print version
print(mtcnn.__version__)
结果:
0.0.9
然后我使用以下内容:
# prepare model
model = MTCNN()
# detect face in the image
faces = model.detect_faces(pixels)
# extract details of the face
x1, y1, width, height = faces[0]['box']
结果:
1 # prepare model
----> 2 model = MTCNN()
3 # detect face in the image
4 faces = model.detect_faces(pixels)
5 # extract details of the face
NameError: name 'MTCNN' is not defined
文档是一个很好的起点:https://github.com/ipazc/mtcnn
from mtcnn.mtcnn import MTCNN
import cv2
model = MTCNN()
有时人们所做的是将他们正在处理的文件命名为 mtcnn.py,这会导致此错误。将文件名 mtcnn.py 更改为其他名称即可。