为什么会出现以下错误:
int()参数必须是字符串,类似字节的对象或数字,而不是“ NoneType”
我认为我需要帮助弄清楚如何将无类型变量转换为字符串或整数,您可以通过以下代码帮助我解决问题吗?
fi = open("model.ckpt-45778","w")
for x in sorted(os.listdir("images")):
# Acquire frame and expand frame dimensions to have shape: [1, None,None, 3]
# i.e. a single-column array, where each item in the column has the pixel RGB value
print(os.path.join("images", x))
frame = cv2.imread(os.path.join("images", x))
frame_expanded = np.expand_dims(frame, axis=0)
#print(frame)
# Perform the actual detection by running the model with the image as input
(boxes, scores, classes, num) = sess.run(
[detection_boxes, detection_scores, detection_classes,num_detections],
feed_dict={image_tensor: frame_expanded})
print(len(scores[0]))
print(scores)
print(len(classes[0]))
print(classes)
maxv = {}
for i in range(1, NUM_CLASSES+1):
maxv[i]=0
for i in range(0, len(scores[0])):
maxv[classes[0][i]]=max(maxv[classes[0][i]],scores[0][i])
print(maxv)
for i in range(1, NUM_CLASSES+1):
fi.write(str(maxv[i])+"\t")
fi.write("\n")
# Draw the results of the detection (aka 'visulaize the results')
vis_util.visualize_boxes_and_labels_on_image_array(
frame,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8,
min_score_thresh=0.60)
cv2.imwrite(os.path.join("test_timeline", x), frame)
#print(frame)
# All the results have been drawn on the frame, so it's time to display it.
cv2.imshow('Object detector', frame)
cv2.imwrite('Salida/' + str(x), frame)
# Press 'q' to quit
if cv2.waitKey(1) == ord('q'):
break
# Clean up
#video.release()
cv2.destroyAllWindows()
images\test Traceback (most recent call last): File "C:\Tensor\models\research\object_detection\Webcam0.py", line 88, in feed_dict={image_tensor: frame_expanded}) File "C:\Users\Tg\Anaconda3\envs\Tensor\lib\site-packages\tensorflow\python\client\session.py", line 950, in run run_metadata_ptr) File "C:\Users\Tg\Anaconda3\envs\Tensor\lib\site-packages\tensorflow\python\client\session.py", line 1142, in _run np_val = np.asarray(subfeed_val, dtype=subfeed_dtype) File "C:\Users\Tg\Anaconda3\envs\Tensor\lib\site-packages\numpy\core\numeric.py", line 538, in asarray return array(a, dtype, copy=False, order=order) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'