【发布时间】:2020-09-13 03:23:53
【问题描述】:
在使用 haarcasde 文件检测后从面部检测到图像后。 但是我收到了这个错误
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_string_ops.py in substr(input, pos, len, unit, name)
1888 _result = pywrap_tfe.TFE_Py_FastPathExecute(
1889 _ctx._context_handle, tld.device_name, "Substr", name,
-> 1890 tld.op_callbacks, input, pos, len, "unit", unit)
1891 return _result
1892 except _core._FallbackException:
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type int).
这是我的代码
def detect_and_noise_face(img):
# Watch solutions video for line by line explanation!
face_img = img.copy()
roi = img.copy()
face_rects = face_cascade.detectMultiScale(face_img,scaleFactor=1.3, minNeighbors=3)
for (x,y,w,h) in face_rects:
roi = roi[y:y+h,x:x+w]
image = tf.image.decode_image(roi)
return face_img
我为什么要解码图像,因为我试图在该 roi 上创建对抗性示例。 https://www.tensorflow.org/tutorials/generative/adversarial_fgsm 谢谢。
【问题讨论】:
标签: python numpy opencv tensorflow