def get_iou(data_list, class_num, save_path=None): import multiprocessing as mp from deeplab.metric import ConfusionMatrix ConfM = ConfusionMatrix(class_num) f = ConfM.generateM pool = mp.Pool() # Mapping the function f to the dataset ''' https://hg.python.org/cpython/file/2.7/Lib/multiprocessing/pool.py States that chunksize, extra = samples // 4 * num_workers if extra: chunksize += 1 ''' m_list = pool.map(f, data_list, chunksize=625) # Validation set 10,000 length pool.close() pool.join() for m in m_list: ConfM.addM(m) aveJ, j_list, M = ConfM.jaccard() print('meanIOU: ' + str(aveJ) + '\n') if save_path: with open(save_path, 'w') as f: f.write('meanIOU: ' + str(aveJ) + '\n') f.write(str(j_list)+'\n') f.write(str(M)+'\n')
def get_iou(data_list, class_num, save_path=None): from multiprocessing import Pool from deeplab.metric import ConfusionMatrix ConfM = ConfusionMatrix(class_num) f = ConfM.generateM pool = Pool() m_list = pool.map(f, data_list) pool.close() pool.join() for m in m_list: ConfM.addM(m) aveJ, j_list, M = ConfM.jaccard() print('meanIOU: ' + str(aveJ) + '\n')
def get_iou(data_list, class_num, save_path=None): from multiprocessing import Pool from deeplab.metric import ConfusionMatrix #混淆矩阵/误差矩阵 检测分类的正确率 ConfM = ConfusionMatrix(class_num) f = ConfM.generateM #f是生成的误差矩阵? pool = Pool() m_list = pool.map(f, data_list) pool.close() pool.join() for m in m_list: ConfM.addM(m) aveJ, j_list, M = ConfM.jaccard() #M为jaccard相似系数 越大样本相似度越高 print('meanIOU: ' + str(aveJ) + '\n') if save_path: with open(save_path, 'w') as f: f.write('meanIOU: ' + str(aveJ) + '\n') f.write(str(j_list) + '\n') f.write(str(M) + '\n')
def get_iou(data_list, class_num, hue_val, save_path=None): from multiprocessing import Pool from deeplab.metric import ConfusionMatrix ConfM = ConfusionMatrix(class_num) f = ConfM.generateM pool = Pool() m_list = pool.map(f, data_list) pool.close() pool.join() for m in m_list: ConfM.addM(m) aveJ, j_list, M = ConfM.jaccard() print('hue value is {}'.format(hue_val)) print('meanIOU: ' + str(aveJ) + '\n') print('class scores: ' + str(j_list) + '\n') if save_path: with open(save_path, 'w') as f: f.write('meanIOU: ' + str(aveJ) + '\n') f.write(str(j_list) + '\n') f.write(str(M) + '\n')