简单的dlib程序让我的电脑崩溃

问题描述:

我在pycharm 64bit上运行python 3.6 64位的简单程序。简单的dlib程序让我的电脑崩溃

然而,大约三次中的两次我运行它,我的电脑突然冻结,我无法做其他事情,我必须按下电源按钮将其关闭。

我怀疑它确实使用了太多的RAM,但我不确定它来自哪里。

下面是代码:

from imutils import face_utils 
import numpy as np 
import argparse 
import imutils 
import dlib 
import cv2 

detector = dlib.get_frontal_face_detector() 
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") 

image = cv2.imread("obama.jpg") 
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) 

rects = detector(gray, 1) 


for (i, rect) in enumerate(rects): 

    shape = predictor(gray, rect) 
    shape = face_utils.shape_to_np(shape) 
    (x, y, w, h) = face_utils.rect_to_bb(rect) 
    cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2) 
    cv2.putText(image, "Face #{}".format(i + 1), (x - 10, y - 10),cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2) 
    for (x, y) in shape: 
     cv2.circle(image, (x, y), 1, (0, 0, 255), -1) 

cv2.imshow("Output", image) 
cv2.waitKey(0) 
+0

为什么你怀疑它使用太多的RAM?您是否监控过其他系统瓶颈,如分页,光盘和网络IO?你在使用哪种操作系统? – cdarke

+0

这只是一个假设,因为我无法监控任何事情:几秒钟后,我启动程序一切都冻结在我的电脑上:/ 我使用的是Windows 8.1 – Tiffany

+1

在运行程序之前启动显示器,你的屏幕的一部分,然后开始你的跑步,而你看指标。 – cdarke

好感谢cdarke我发现通过我的电池使用情况,以“高性能”解决了这个问题。