python - MemoryError:当 Pycharm 几乎没有显示任何内存使用时分配错误
问题描述
所以我在 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 x 1080。总共 17 张图像。我的电脑没有gpu,所以我不确定这是否是问题所在。
我也检查了任务管理器,程序崩溃时内存使用量约为 50%。
我的电脑是 Hp Spectre x360 i5 第 6 代 8gb 内存。2岁,如果这很重要。
解决方案
刚刚意识到问题是我的代码配置为使用 gpu 运行。我的错...将默认检测方法从“cnn”更改为“hog”。
推荐阅读
- android - How can i create this type of user interface?
- c - C program with fifo is not working, Unix console waits for input
- flutter - Custom notification channel for FCM in flutter
- php - HTML tags replacing with php
- c# - 如何在 Unity 中创建一个简单的 FirstPersonController:编译器错误消息?
- ios - Unable to Dequeue viewForSupplementaryElementOfKind '未检索到返回的视图'
- android - APP_ID 和 API_KEY 有其他选择吗?
- angular - 基于具有值或为空的两个字段的 Angular FormControl XNOR 验证器
- r - 通过变量和框变量标题ggplot为背景着色
- python - 在 SqlAlchemy 模型中存储字典