Open billtiger opened 7 years ago
when I run this project to do face detect with tensorflow 1.2 version on the ubuntu 14.04, I met the error:
2017-10-13 00:39:02.833148: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Found device 0 with properties: name: Tesla M40 major: 5 minor: 2 memoryClockRate(GHz): 1.112 pciBusID: 0000:82:00.0 totalMemory: 11.93GiB freeMemory: 11.82GiB 2017-10-13 00:39:02.833193: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1055] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Tesla M40, pci bus id: 0000:82:00.0, compute capability: 5.2) 2017-10-13 00:39:02.863038: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 11.93G (12808486912 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
It seem the 12G memory is not enough for mtcnn model. Could you tell me which GPU device you use, how much memory does the mtcnn detection algorith need? @billtiger
@so-as Change "per_process_gpu_memory_fraction=[x]" to "per_process_gpu_memory_fraction=0.4"
I have the same issue @billtiger It's can solved by
thanks,you solved my problem!it worked! @samrid
i can run mtcnn on my i5 CPU computer,so it doesn't need much memory,you can check there are other reason cause this error? @so-as
@billtiger and @samrid guys, i am also having same problem as @billtiger. I did the changes as suggested by @samrid. But, still having the same classification issue. Can you guys please have a look at my code. Thanks!!
OR
cropped.append(frame[bb[i][1]:bb[i][3], bb[i][0]:bb[i][2], :])
cropped[i] = facenet.flip(cropped[i], False)
##scaled.append(misc.imresize(cropped[0], (image_size, image_size), interp='bilinear'))
scaled.append(misc.imresize(cropped[i], (image_size, image_size), interp='bilinear'))
##scaled[0] = cv2.resize(scaled[0], (input_image_size,input_image_size),interpolation=cv2.INTER_CUBIC)
scaled[i] = cv2.resize(scaled[i], (input_image_size,input_image_size),interpolation=cv2.INTER_CUBIC)
##scaled[0] = facenet.prewhiten(scaled[0])
scaled[i] = facenet.prewhiten(scaled[i])
##scaled_reshape.append(scaled[0].reshape(-1,input_image_size,input_image_size,3))
scaled_reshape.append(scaled[i].reshape(-1,input_image_size,input_image_size,3))
##feed_dict = {images_placeholder: scaled_reshape[0], phase_train_placeholder: False}
feed_dict = {images_placeholder: scaled_reshape[i], phase_train_placeholder: False}
emb_array[0, :] = sess.run(embeddings, feed_dict=feed_dict)
predictions = model.predict_proba(emb_array)
best_class_indices = np.argmax(predictions, axis=1)
best_class_probabilities = predictions[np.arange(len(best_class_indices)), best_class_indices]
cv2.rectangle(frame, (bb[i][0], bb[i][1]), (bb[i][2], bb[i][3]), (0, 255, 0), 2) #boxing face
same with @GarvLodha i still have the same problemm
@dwikysyahbana , try this:
j = 0 #appended for i in range(nrof_faces): emb_array = np.zeros((1, embedding_size))
bb[i][0] = det[i][0]
bb[i][1] = det[i][1]
bb[i][2] = det[i][2]
bb[i][3] = det[i][3]
# inner exception
if bb[i][0] <= 0 or bb[i][1] <= 0 or bb[i][2] >= len(frame[0]) or bb[i][3] >= len(frame):
print('face is inner of range!')
continue
cropped.append(frame[bb[i][1]:bb[i][3], bb[i][0]:bb[i][2], :])
##cropped[0] = facenet.flip(cropped[0], False)
##cropped[i] = facenet.flip(cropped[i], False)
cropped[j] = facenet.flip(cropped[j], False)
##scaled.append(misc.imresize(cropped[0], (image_size, image_size), interp='bilinear'))
##scaled.append(misc.imresize(cropped[i], (image_size, image_size), interp='bilinear'))
scaled.append(misc.imresize(cropped[j], (image_size, image_size), interp='bilinear'))
##scaled[0] = cv2.resize(scaled[0], (input_image_size,input_image_size),interpolation=cv2.INTER_CUBIC)
##scaled[i] = cv2.resize(scaled[i], (input_image_size,input_image_size),interpolation=cv2.INTER_CUBIC)
scaled[j] = cv2.resize(scaled[j], (input_image_size,input_image_size),interpolation=cv2.INTER_CUBIC)
##scaled[0] = facenet.prewhiten(scaled[0])
##scaled[i] = facenet.prewhiten(scaled[i])
scaled[j] = facenet.prewhiten(scaled[j])
##scaled_reshape.append(scaled[0].reshape(-1,input_image_size,input_image_size,3))
##scaled_reshape.append(scaled[i].reshape(-1,input_image_size,input_image_size,3))
scaled_reshape.append(scaled[j].reshape(-1,input_image_size,input_image_size,3))
##feed_dict = {images_placeholder: scaled_reshape[0], phase_train_placeholder: False}
##feed_dict = {images_placeholder: scaled_reshape[i], phase_train_placeholder: False}
feed_dict = {images_placeholder: scaled_reshape[j], phase_train_placeholder: False}
emb_array[0, :] = sess.run(embeddings, feed_dict=feed_dict)
predictions = model.predict_proba(emb_array)
best_class_indices = np.argmax(predictions, axis=1)
best_class_probabilities = predictions[np.arange(len(best_class_indices)), best_class_indices]
cv2.rectangle(frame, (bb[i][0], bb[i][1]), (bb[i][2], bb[i][3]), (0, 255, 0), 2) #boxing face
#plot result idx under box
text_x = bb[i][0]
text_y = bb[i][3] + 20
##print('result: ', best_class_indices[0])
print('result: ', best_class_indices[0])
print('prob: ', best_class_probabilities[0])
if best_class_probabilities > 0.40:
for H_i in HumanNames:
##if HumanNames[best_class_indices[0]] == H_i:
if HumanNames[best_class_indices[0]-1] == H_i:
##result_names = HumanNames[best_class_indices[0]]
result_names = HumanNames[best_class_indices[0]-1]
cv2.putText(frame, result_names, (text_x, text_y), cv2.FONT_HERSHEY_COMPLEX_SMALL,1, (0, 0, 255), thickness=1, lineType=2)
else:
cv2.putText(frame,'unknown', (text_x, text_y), cv2.FONT_HERSHEY_COMPLEX_SMALL,1, (0, 0, 255), thickness=1, lineType=2)
j += 1
else:
print('Unable to align')
I have the same issue @billtiger It's can solved by
- Change "cropped[0]" to "cropped[i]"
- Change "scaled[0]" to "scaled[i]"
- Change "scaled_reshape[0]" to "scaled_reshape[i]" it's worked for me. thank @bearsprogrammer for your shared.
I also still having the same issue
@billtiger and @samrid guys, i am also having same problem as @billtiger. I did the changes as suggested by @samrid. But, still having the same classification issue. Can you guys please have a look at my code. Thanks!!
OR
cropped.append(frame[bb[i][1]:bb[i][3], bb[i][0]:bb[i][2], :])
cropped[0] = facenet.flip(cropped[0], False)
cropped[i] = facenet.flip(cropped[i], False)
scaled.append(misc.imresize(cropped[0], (image_size, image_size), interp='bilinear'))
scaled.append(misc.imresize(cropped[i], (image_size, image_size), interp='bilinear'))
scaled[0] = cv2.resize(scaled[0], (input_image_size,input_image_size),interpolation=cv2.INTER_CUBIC)
scaled[i] = cv2.resize(scaled[i], (input_image_size,input_image_size),interpolation=cv2.INTER_CUBIC)
scaled[0] = facenet.prewhiten(scaled[0])
scaled[i] = facenet.prewhiten(scaled[i])
scaled_reshape.append(scaled[0].reshape(-1,input_image_size,input_image_size,3))
scaled_reshape.append(scaled[i].reshape(-1,input_image_size,input_image_size,3))
feed_dict = {images_placeholder: scaled_reshape[0], phase_train_placeholder: False}
feed_dict = {images_placeholder: scaled_reshape[i], phase_train_placeholder: False} emb_array[0, :] = sess.run(embeddings, feed_dict=feed_dict) predictions = model.predict_proba(emb_array) best_class_indices = np.argmax(predictions, axis=1) best_class_probabilities = predictions[np.arange(len(best_class_indices)), best_class_indices] cv2.rectangle(frame, (bb[i][0], bb[i][1]), (bb[i][2], bb[i][3]), (0, 255, 0), 2) #boxing face
Yesterday I also had the same issue. Solved it by fixing path. In the Make_classifier_git.py file 1st path has to be the folder of aligned images. I mistakenly did path to the original image folder, not to the aligned image folder. I hope this solves your problem
same with @GarvLodha i still have the same problemm
I just suggest an solution in the above
when I have two persons to detect, it could detect two person! but the classification is also the same when detect two person,e.g.two person's name are bill and lisa,the classification result is two person are bill or two person are lisa,what's the problem?your reply for my problem will be highly appreciated!thank you! @bearsprogrammer