python各种问题:'NoneType' object has no attribute 'shape';Expected 2D array, got 1D array instead:

if __name__ =="__main__":
    img_path=r"./smoke/allsmoke/image_3.jpg"
    #img_path='./data/imagePart_train/smoke/allsmoke/image_3.jpg'
    img = cv2.imread(img_path)
    print(img.shape)
    f=getFeature(img, 5)
    print(f)

问题1: print(img.shape)
               AttributeError: 'NoneType' object has no attribute 'shape'

解决方案:把img_path的路径写全,或者好好检查该路径下是否有图像

问题2:ValueError: Expected 2D array, got 1D array instead:

解决方案:在下图所示的地方加上[ ]即可!

猜你喜欢

转载自blog.csdn.net/jiangsujiangjiang/article/details/84188071