笔记本电脑,显卡为mx450 2G独显,现在出问题了。代码
import os
import face_recognition
import time
time_start=time.time()
gilr_image = face_recognition.load_image_file("suzy.jpg")
girl_encoding = face_recognition.face_encodings(gilr_image)[0]
'''
img = face_recognition.load_image_file("temp/frame000119.jpg")
locations = face_recognition.face_locations(img,model="cnn")
for l in locations:
print(l)
face_encodings = face_recognition.face_encodings(img,known_face_locations=locations)
results = face_recognition.compare_faces(face_encodings, girl_encoding)
for rsl in results:
print(rsl)
'''
img1 = face_recognition.load_image_file("temp/frame000059.jpg")
img2 = face_recognition.load_image_file("temp/frame000120.jpg")
img = []
img.append(img1)
img.append(img2)
batch_of_face_locations = face_recognition.batch_face_locations(img, number_of_times_to_upsample=1,batch_size=2)
这里number_of_times_to_upsample设为0就没事,设为1 就报
return cnn_face_detector(images, number_of_times_to_upsample, batch_size=batch_size)
RuntimeError: Error while calling cudnnFindConvolutionForwardAlgorithm( context(), descriptor(data), (const cudnnFilterDescriptor_t)filter_handle, (const cudnnConvolutionDescriptor_t)conv_handle, descriptor(dest_desc), num_possible_algorithms, &num_algorithms, perf_results.data()) in file G:\dlib-19.22\dlib\cuda\cudnn_dlibapi.cpp:820. code: 2, reason: CUDA Resources could not be allocated.
另一个主要代码是 batch_of_face_locations = face_recognition.batch_face_locations(frames, number_of_times_to_upsample=0)#batch_size=128默认。这里报Out of memory 。这个我看了一会源代码了,python的dlib只看到了api,不知道python部分源代码在哪
class dlib.cnn_face_detection_model_v1
This object detects human faces in an image. The constructor loads the face detection model from a file. You can download a pre-trained model from http://dlib.net/files/mmod_human_face_detector.dat.bz2.
__call__(*args, **kwargs)
Overloaded function.
__call__(self: dlib.cnn_face_detection_model_v1, imgs: list, upsample_num_times: int=0L, batch_size: int=128L) -> std::vector<std::vector<dlib::mmod_rect, std::allocator<dlib::mmod_rect> >, std::allocator<std::vector<dlib::mmod_rect, std::allocator<dlib::mmod_rect> > > >
takes a list of images as input returning a 2d list of mmod rectangles
__call__(self: dlib.cnn_face_detection_model_v1, img: array, upsample_num_times: int=0L) -> std::vector<dlib::mmod_rect, std::allocator<dlib::mmod_rect> >
Find faces in an image using a deep learning model.
Upsamples the image upsample_num_times before running the face detector.
__init__(self: dlib.cnn_face_detection_model_v1, filename: unicode) → None
不知道这api源代码在哪,C++部分这么关联上,以前做JAVA的,所以我也不懂它这里面是这么扩展的,我觉得没多少数据啊,
这么装不下,是不是我要加上什么设置啊。有懂的帮 帮我吧