MemoryError:Pycharm几乎不显示任何内存使用情况时分配错误

时间:2019-02-23 01:26:13

标签: python pickle face-recognition dlib cv2

因此,我正在Pycharm环境中关注https://www.pyimagesearch.com/2018/06/18/face-recognition-with-opencv-python-and-deep-learning/上的教程。当我运行面部编码文件时,会出现此错误。

Traceback (most recent call last):
File "Encoding_Faces.py", line 29, in <module>
boxes = face_recognition.face_locations(rgb, model=args["detection_method"])
File "C:\Users\my name\AppData\Local\Programs\Python\Python36- 
32\Webcam_Face_Detect\lib\site-packages\face_recognition\api.py", line 116, 
in face_locations
return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in 
_raw_face_locations(img, number_of_times_to_upsample, "cnn")]
File "C:\Users\my name\AppData\Local\Programs\Python\Python36- 
32\Webcam_Face_Detect\lib\site-packages\face_recognition\api.py", line 100, 
in _raw_face_locations
return cnn_face_detector(img, number_of_times_to_upsample)
MemoryError: bad allocation

但是,当我在屏幕右下方看到内存使用情况时,它大约是4096M中的200。我将内存从750M增加到无济于事。奇怪的是,错误发生在第一张照片本身上。我的图像分别约为200kb和1920 x1080。共有17张图像。我的计算机没有GPU,所以我不确定是否是问题所在。

我也检查了任务管理器,程序崩溃时内存使用率约为50%。

我的计算机是Hp Spectre x360 i5第六代8GB内存。重要的是2岁。

1 个答案:

答案 0 :(得分:0)

刚意识到问题是我将我的代码配置为与gpu一起运行。糟糕...将默认检测方法从“ cnn”更改为“ hog”。