test_predict = total_image_predict( ori_image_path=args.test_image_path, input_placeholder=image, logits_prob_node=logits_prob, is_training_placeholder=model._is_training, sess=sess, multi_scale=args.multi_scale) test_label = cv2.imread(args.test_label_path, cv2.IMREAD_GRAYSCALE) # 保存图片 cv2.imwrite(filename='%spredict_color_%d.png' % (log_path, step), img=color_predicts(img=test_predict)) result = iou(y_pre=np.reshape(test_predict, -1), y_true=np.reshape(test_label, -1)) print("======================%d======================" % step) for key in result.keys(): offset = 40 - key.__len__() print(key + ' ' * offset + '%.4f' % result[key]) test_summary = tf.Summary(value=[ tf.Summary.Value(tag=key, simple_value=result[key]) for key in result.keys() ]) # 记录summary summary_writer.add_summary(test_summary, step) summary_writer.flush() saver.save(sess, model_path, write_meta_graph=True, global_step=100000)
(512, 512)).reshape((512, 512, 1)) img = np.concatenate((img_rgb, img_thermal), axis=2) else: img_rgb = cv2.imread(line[0], cv2.IMREAD_COLOR) img_rgb = cv2.resize(img_rgb, (512, 512)) img = img_rgb test_predict = multi_scale_predict( image=img, input_placeholder=image, is_training_placeholder=model._is_training, logits_prob_node=logits_prob, sess=sess, multi=False, size=512) g_truth = cv2.resize(np.array(Image.open(line[2])), (512, 512)) result = iou(y_pre=np.reshape(test_predict, -1), y_true=np.reshape(g_truth, -1)) label_valid = np.unique(g_truth) for key in sorted(result.keys()): if key in key_map and not key_map[key] in label_valid: continue if np.isnan(result[key]) or result[key] != result[key]: continue if not key in all_tests_result: all_tests_result[key] = [result[key]] else: all_tests_result[key].append(result[key]) test_label = color_predicts(img=g_truth) test_predict = color_predicts(img=test_predict) full_image = np.concatenate((img_rgb, test_label, test_predict), axis=1) out_name = line[0].split('/')[-1].split('.')[0] + '_predict.jpg'