def augmentImages_test(): # bug:包和包之间无法互相调用,只能注释另一个,或者放from xxx.preprocess import xxx放这里 from data_process.use_seg_tfrecord import create_inputs_seg_hand images, masks = create_inputs_seg_hand(is_train=True) session_config = tf.ConfigProto( device_count={'GPU': 0}, gpu_options={ 'allow_growth': 1, # 'per_process_gpu_memory_fraction': 0.1, 'visible_device_list': '0' }, allow_soft_placement=True) ##这个设置必须有,否则无论如何都会报cudnn不匹配的错误,BUG十分隐蔽,真是智障 with tf.Session(config=session_config) as sess: tf.global_variables_initializer().run() tf.local_variables_initializer().run() coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(sess=sess, coord=coord) # 输出100个batch观察 for i in range(100): batch_size_n = 1 # 观察batch_size的第n张图片 pics, pics_masks = sess.run([images, masks]) # 取出一个batchsize的图片 ########################## 主要调用的东西 ############################ pics = pics / 255 x_aug, y_aug = augmentImages(pics, pics_masks) ########################## end ####################################### pics = np.split(x_aug, cfg.batch_size, axis=0) # 按图片数量切分batchsize张 pic = pics[batch_size_n] # pic = pic 255 pic = np.squeeze(pic, axis=0) # 去掉维度是1的维度,四维变成三维 pics_masks = np.split(y_aug, cfg.batch_size, axis=0) # 按图片数量切分batchsize张 pics_mask = pics_masks[batch_size_n] pics_mask = np.squeeze(pics_mask, axis=0) # 去掉维度是1的维度,四维变成三维 pics_mask = cv2.cvtColor(pics_mask, cv2.COLOR_GRAY2BGR) # 一通道转三通道 hstack = np.hstack((pic, pics_mask)) # 水平拼接 if cv2_show: cv2.imshow('img and mask', hstack) cv2.waitKey(2000) cv2.destroyAllWindows() else: plt_imshow_data(hstack) time.sleep(2) coord.request_stop() coord.join(threads)
mean_list = [ AUC_ROC_mean, AUC_prec_rec_mean, accuracy_mean, specificity_mean, sensitivity_mean, precision_mean, jaccard_index_mean, F1_score_mean ] data = {} index = 1 # 只有一行 (为何不加这个index就会报错) for name, mean in zip(name_list, mean_list): data.update({name: mean}) mean_result = pd.DataFrame(data, index=[index]) mean_result.to_csv(save_mean_csv, encoding='gbk') print('save to {}'.format(save_mean_csv)) if __name__ == '__main__': images, labels = create_inputs_seg_hand(is_train=is_train) session_config = tf.ConfigProto( device_count={'GPU': 0}, gpu_options={ 'allow_growth': 1, # 'per_process_gpu_memory_fraction': 0.1, 'visible_device_list': '0' }, allow_soft_placement=True) ##这个设置必须有,否则无论如何都会报cudnn不匹配的错误,BUG十分隐蔽,真是智障 with tf.Session(config=session_config) as sess: # 1、先定义model才能执行第二步的初始化 model = SegCaps(sess, cfg, is_train=is_train) # 2、初始化和启动线程 tf.global_variables_initializer().run()