python - 内存错误: bad allocation when Pycharm shows barely any memory use

标签 python pickle face-recognition dlib opencv

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

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 x 1080。总共 17 张图像。我的电脑没有 GPU,所以我不确定这是否是问题所在。

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

我的电脑是 Hp Spectre x360 i5 第 6 代 8GB 内存。 2 岁,如果这很重要的话。

最佳答案

刚刚意识到问题是我的代码配置为使用 GPU 运行。我的错...将默认检测方法从“cnn”更改为“hog”。

关于python - 内存错误: bad allocation when Pycharm shows barely any memory use,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54837311/

相关文章:

python - 类型错误 : can't pickle NotImplementedType objects (in keras, python )

python - sklearn 和 n_jobs 中的超参数优化 > 1 : Pickling

python - 在 Python 版本之间通过套接字发送 numpy 数组,ascii 错误

python - 在python中存储面部编码列表以进行面部识别

python - 从 blender 导出以在 ogl 中查看的正确骨骼数据?

python - sqlalchemy,说小数没有定义?

python 数据帧 : get 'set' from DataFrame elements

python - 将多个 xlsx 文件合并为一个

math - 使用地标比较人脸?

ios - 继续记录丢失的服务器连接以获取 kct 连接无效通知