从 skimage 导入 io 错误追溯

Posted

技术标签:

【中文标题】从 skimage 导入 io 错误追溯【英文标题】:From skimage import io error trace back 【发布时间】:2017-11-05 03:33:19 【问题描述】:

我正在尝试使用 dlib 进行人脸识别。但是当我执行程序时,skimage 出现错误。有人可以帮助我吗?我试图解决它,但我不能

from skimage.io import imread
import sys
import os
import dlib
import glob
import numpy



if len(sys.argv) != 4:
print(
    "Call this program like this:\n"
    "   ./face_recognition.py shape_predictor_68_face_landmarks.dat dlib_face_recognition_resnet_model_v1.dat ../examples/faces\n"
    "You can download a trained facial shape predictor and recognition model from:\n"
    "    http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2\n"
    "    http://dlib.net/files/dlib_face_recognition_resnet_model_v1.dat.bz2")
exit()

 predictor_path = sys.argv[1]
 face_rec_model_path = sys.argv[2]
 faces_folder_path = sys.argv[3]


 detector = dlib.get_frontal_face_detector()
 sp = dlib.shape_predictor(predictor_path)
 facerec = dlib.face_recognition_model_v1(face_rec_model_path)

 win = dlib.image_window()


for f in glob.glob(os.path.join(faces_folder_path, "*.jpg")):
print("Processing file: ".format(f))
img = io.imread(f)

win.clear_overlay()
win.set_image(img)

# Ask the detector to find the bounding boxes of each face. The 1 in the
# second argument indicates that we should upsample the image 1 time. This
# will make everything bigger and allow us to detect more faces.
dets = detector(img, 1)
print("Number of faces detected: ".format(len(dets)))

# Now process each face we found.
for k, d in enumerate(dets):
    print("Detection : Left:  Top:  Right:  Bottom: ".format(
        k, d.left(), d.top(), d.right(), d.bottom()))
    # Get the landmarks/parts for the face in box d.
    shape = sp(img, d)
    # Draw the face landmarks on the screen so we can see what face is currently being processed.
    win.clear_overlay()
    win.add_overlay(d)
    win.add_overlay(shape)

    # Compute the 128D vector that describes the face in img identified by
    # shape.  In general, if two face descriptor vectors have a Euclidean
    # distance between them less than 0.6 then they are from the same
    # person, otherwise they are from different people.  He we just print
    # the vector to the screen.
    face_descriptor = facerec.compute_face_descriptor(img, shape)
    print(face_descriptor)
    # It should also be noted that you can also call this function like this:
    #  face_descriptor = facerec.compute_face_descriptor(img, shape, 100)
    # The version of the call without the 100 gets 99.13% accuracy on LFW
    # while the version with 100 gets 99.38%.  However, the 100 makes the
    # call 100x slower to execute, so choose whatever version you like.  To
    # explain a little, the 3rd argument tells the code how many times to
    # jitter/resample the image.  When you set it to 100 it executes the
    # face descriptor extraction 100 times on slightly modified versions of
    # the face and returns the average result.  You could also pick a more
    # middle value, such as 10, which is only 10x slower but still gets an
    # LFW accuracy of 99.3%.


    dlib.hit_enter_to_continue()

我的错误信息是这样的

Traceback (most recent call last):
File "C:/Users/android/Downloads/Compressed/dlib-19.4/dlib-19.4/python_examples/face_recognition.py", line 48, in <module>
from skimage.io import imread
File "C:\Users\Android\AppData\Local\Programs\Python\Python35\lib\site-packages\skimage\io\__init__.py", line 11, in <module>
from ._io import *
File "C:\Users\Android\AppData\Local\Programs\Python\Python35\lib\site-packages\skimage\io\_io.py", line 7, in <module>
from ..color import rgb2grey
File "C:\Users\Android\AppData\Local\Programs\Python\Python35\lib\site-packages\skimage\color\__init__.py", line 1, in <module>
from .colorconv import (convert_colorspace,
File "C:\Users\Android\AppData\Local\Programs\Python\Python35\lib\site-packages\skimage\color\colorconv.py", line 59, in <module>
from scipy import linalg
File "C:\Users\Android\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'

请帮我解决我的问题。之前谢谢你

【问题讨论】:

【参考方案1】:

可以从 mahotas 包中获得 Imread。

例子:

import mahotas as mh  
from mahotas.features import surf  
image = mh.imread('zipper.jpg', as_grey=True) 

【讨论】:

以上是关于从 skimage 导入 io 错误追溯的主要内容,如果未能解决你的问题,请参考以下文章

PyQt5 在导入 skimage 时出现问题

ImportError:导入 _remap 时 DLL 加载失败

python skimage模块处理图片

PHONEGAP - 无法导入证书 - IOS

Sqoop 导入错误 Error: java.io.IOException: SQLException in nextKeyValue

升级 scikit-image 版本的问题