1.验证集val.txt验证测试结果可视化~

一步到位!!!批量验证集测试!!!

import sys
sys.path.append("..")
sys.path.insert(0, '.')
import argparse
import torch
import torch.nn as nn
from PIL import Image
import numpy as np
import cv2
import time
import os #要导入osimport lib.transform_cv2 as T
from lib.models import model_factory
from configs import set_cfg_from_filefrom tqdm import tqdmtorch.set_grad_enabled(False)
np.random.seed(123)sys.path.append('G:\\addwater0906\\')val_path = "G:\\addwater0906\\val\\"     # val验证集的路径
data = []
i = 0for line in open("G:\\addwater0906\\val.txt", "r"):  # 设置文件对象并读取每一行文件data.append(line)
for img in data:filename = img.split(",")print(filename[0])a = cv2.imread("G:\\addwater0906\\"+filename[0])   # 原图img的路径b = os.path.split(filename[0])[-1]  # 去路径下最后一级cv2.imwrite(val_path + b, a)i += 1print("一共验证集val多少图片:", i)
# args
parse = argparse.ArgumentParser()
#parse.add_argument('--config', dest='config', type=str, default='BiSeNet-master/configs/bisenetv2_city.py',)
parse.add_argument('--config', dest='config', type=str, default='./configs/bisenetv2_city.py',)
# parse.add_argument('--weight-path', type=str, default='BiSeNet-master/res/model_final_v2_city.pth',)
parse.add_argument('--weight-path', type=str, default='./waterv3_model_final.pth',)  # 模型的路径!!!!
#parse.add_argument('--weight-path', type=str, default='./res/model_final.pth',)
#parse.add_argument('--img-path', dest='img_path', type=str, default='BiSeNet-master/example.png',)
parse.add_argument('--img_path', dest='img_path', type=str, default= val_path,)
args = parse.parse_args()
cfg = set_cfg_from_file(args.config)palette = np.random.randint(0, 256, (256, 3), dtype=np.uint8)# define model
net = model_factory[cfg.model_type](cfg.n_cats, aux_mode='pred')
net.load_state_dict(torch.load(args.weight_path, map_location='cpu'), strict=False)
net.eval()
# net.cuda()# prepare data
to_tensor = T.ToTensor(mean=(0.3257, 0.3690, 0.3223), # city, rgbstd=(0.2112, 0.2148, 0.2115),
)
dir_path = args.img_pathfor file_name in tqdm(os.listdir(dir_path)):path = val_path + file_name #这里表示其中一张图像的路径im = cv2.imread(path)[:, :, ::-1]  # 主要是这里读入的路径# 后面的接着写就行# im = to_tensor(dict(im=im, lb=None))['im'].unsqueeze(0).cuda()im = to_tensor(dict(im=im, lb=None))['im'].unsqueeze(0)# inferencet1 = time.time()out = net(im).squeeze().detach().cpu().numpy()# pred = palette[out]cv2.imwrite('G:\\addwater0906\\val_mask\\' + file_name, out)    # mask输出全黑路径
# print('图像误分割大于8%个数:', count1)
# print('图像误分割大于5%的个数:', count2)# cv2.imwrite('output.jpg', pred)
# cv2.namedWindow("output", cv2.WINDOW_NORMAL)
# cv2.imshow("output", pred)
# cv2.waitKey(0)
import matplotlib.pyplot as plt
from matplotlib import gridspec
import numpy as np
import cv2def create_pascal_label_colormap():colormap = np.zeros((256, 3), dtype=int)ind = np.arange(256, dtype=int)for shift in reversed(range(8)):for channel in range(3):colormap[:, channel] |= ((ind >> channel) & 1) << shiftind >>= 3return colormapdef label_to_color_image(label):if label.ndim != 2:raise ValueError('Expect 2-D input label')colormap = create_pascal_label_colormap()if np.max(label) >= len(colormap):raise ValueError('label value too large.')return colormap[label]def vis_segmentation(image, seg_map):"""输入图片和分割 mask 的可视化."""plt.figure(figsize=(15, 5))grid_spec = gridspec.GridSpec(1, 4, width_ratios=[6, 6, 6, 1])plt.subplot(grid_spec[0])plt.imshow(image)plt.axis('off')plt.title('input image')plt.subplot(grid_spec[1])seg_image = label_to_color_image(seg_map).astype(np.uint8)plt.imshow(seg_image)plt.axis('off')plt.title('segmentation map')plt.subplot(grid_spec[2])plt.imshow(image)plt.imshow(seg_image, alpha=0.5)plt.axis('off')plt.title('segmentation overlay')unique_labels = np.unique(seg_map)ax = plt.subplot(grid_spec[3])plt.imshow(FULL_COLOR_MAP[unique_labels].astype(np.uint8), interpolation='nearest')ax.yaxis.tick_right()plt.yticks(range(len(unique_labels)), LABEL_NAMES[unique_labels])plt.xticks([], [])ax.tick_params(width=0.0)plt.grid('off')# plt.imsave('G:\\1\\' + image)# plt.show()LABEL_NAMES = np.asarray(['background', 'water'])  # 假设只有两类
FULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)
FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)img_path = 'G:\\addwater0906\\val\\'   # img原图路径
png_path = 'G:\\addwater0906\\val_mask\\'   # mask输出全黑路径
i = 0
for img in os.listdir(img_path):print(img)imgfile = img_path + imgpngfile = png_path + imgnew_path = "G:\\addwater0906\\pltsave\\" + img    #保存新的验证集val.txt测试结果可视化路径!!!img = cv2.imread(imgfile, 1)img = img[:, :, ::-1]seg_map = cv2.imread(pngfile, 0)vis_segmentation(img, seg_map)plt.savefig(new_path)plt.close()i +=1print('可视化总数量:',i)
print('Done.')

生成可视化的video!!!

import cv2
import glob
import os
img_root = "G:\\water\\val_plt\\" # 是图片序列的位置
fps = 3  # 可以随意调整视频的帧速率#可以用(*'DVIX')或(*'X264'),如果都不行先装ffmepg
fourcc = cv2.VideoWriter_fourcc(*'XVID')
videoWriter = cv2.VideoWriter('water.avi',fourcc,fps,(1500,500),True)#(1280,720)是图像序列的尺寸,True指保存为彩色视频,false为灰度视频
j = 0
for i in sorted(glob.glob(os.path.join(img_root, '*'))):j = j+1frame = cv2.imread(i)print('-> load {} picture'.format(j))videoWriter.write(frame)
videoWriter.release()




2.对测试集合统一处理(尺寸、位深等)

单张不规则尺寸测试!!!!!!

import sys
sys.path.append("..")
sys.path.insert(0, '.')
import argparse
import torch
import numpy as np
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = Trueimport lib.transform_cv2 as T
from lib.models import model_factory
from configs import set_cfg_from_filefrom PIL import Image
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = Trueimport matplotlib.pyplot as plt
from matplotlib import gridspec
import cv2torch.set_grad_enabled(False)
np.random.seed(123)path = '00.png'   # 输入图片路径
mask_path = 'G:\\A_water+bisenet\\0922mask\\' # mask输出路径
plt_path = 'G:\\A_water+bisenet\\0922plt\\' # plt可视化路径
imgFile = Image.open(path).convert('RGB')
newImage = imgFile.resize((1024, 2048), Image.BILINEAR)  # resize长度、宽度
path = path.split(".")
path = path[0] + '.png'
newImage.save(path)# args
parse = argparse.ArgumentParser()
parse.add_argument('--config', dest='config', type=str, default='./configs/bisenetv2_city.py',)
parse.add_argument('--weight-path', type=str, default='./waterv5_model_final.pth',)     # 模型路径
parse.add_argument('--img_path', dest='img_path', type=str, default=path,)         # 测试图片输入路径
args = parse.parse_args()
cfg = set_cfg_from_file(args.config)palette = np.random.randint(0, 256, (256, 3), dtype=np.uint8)# define model
net = model_factory[cfg.model_type](cfg.n_cats, aux_mode='pred')
net.load_state_dict(torch.load(args.weight_path, map_location='cpu'), strict=False)
net.eval()
# net.cuda()# prepare data
to_tensor = T.ToTensor(mean=(0.3257, 0.3690, 0.3223), # city, rgbstd=(0.2112, 0.2148, 0.2115),
)
dir_path = args.img_pathim = cv2.imread(path)[:, :, ::-1]  # 主要是这里读入的路径im = to_tensor(dict(im=im, lb=None))['im'].unsqueeze(0)out = net(im).squeeze().detach().cpu().numpy()cv2.imwrite(mask_path + path, out)                      # 这里表示输出mask图像的路径def create_pascal_label_colormap():colormap = np.zeros((256, 3), dtype=int)ind = np.arange(256, dtype=int)for shift in reversed(range(8)):for channel in range(3):colormap[:, channel] |= ((ind >> channel) & 1) << shiftind >>= 3return colormapdef label_to_color_image(label):if label.ndim != 2:raise ValueError('Expect 2-D input label')colormap = create_pascal_label_colormap()if np.max(label) >= len(colormap):raise ValueError('label value too large.')return colormap[label]def vis_segmentation(image, seg_map):"""输入图片和分割 mask 的可视化."""plt.figure(figsize=(15, 5))grid_spec = gridspec.GridSpec(1, 4, width_ratios=[6, 6, 6, 1])plt.subplot(grid_spec[0])plt.imshow(image)plt.axis('off')plt.title('input image')plt.subplot(grid_spec[1])seg_image = label_to_color_image(seg_map).astype(np.uint8)plt.imshow(seg_image)plt.axis('off')plt.title('segmentation map')plt.subplot(grid_spec[2])plt.imshow(image)plt.imshow(seg_image, alpha=0.7)plt.axis('off')plt.title('segmentation overlay')unique_labels = np.unique(seg_map)ax = plt.subplot(grid_spec[3])plt.imshow(FULL_COLOR_MAP[unique_labels].astype(np.uint8), interpolation='nearest')ax.yaxis.tick_right()plt.yticks(range(len(unique_labels)), LABEL_NAMES[unique_labels])plt.xticks([], [])ax.tick_params(width=0.0)plt.grid('off')# plt.show()LABEL_NAMES = np.asarray(['unlabeled','water'])  # 假设只有三类
FULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)
FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)img_path = path  # 原图
png_path = mask_path + path       # mask图(全黑)
plt_path = plt_path + path        # plt图img = cv2.imread(img_path, 1)
img = img[:, :, ::-1]
seg_map = cv2.imread(png_path, 0)
vis_segmentation(img, seg_map)plt.savefig(plt_path)
plt.close()
# plt.clf()

对测试集先统一成(1).jpg/png不固定的格式但顺序排列的图片!!!!
批量测试集测试一步到位!!!

import sys
sys.path.append("..")
sys.path.insert(0, '.')
import argparse
import torch
import torch.nn as nn
from PIL import Image
import numpy as np
import cv2
import time
import os #要导入os
import os
import glob
import os.path
from PIL import Image
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = Trueimport lib.transform_cv2 as T
from lib.models import model_factory
from configs import set_cfg_from_filefrom tqdm import tqdm
import os.path
from PIL import Image
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
import cv2import matplotlib.pyplot as plt
from matplotlib import gridspec
import numpy as np
import cv2
import ostorch.set_grad_enabled(False)
np.random.seed(123)path = "G:\\00000000000000000\\"                  # 输入测试图片路径files = os.listdir(path)                 #会按顺序排列[1,2,3,4,.png]格式
i=0for file in files:original = path + os.sep+ files[i]new = path + os.sep + str(i+1) + ".png"os.rename(original,new)i +=1def Resize(file, outdir, width, height):imgFile = Image.open(file)try:newImage = imgFile.resize((width, height), Image.BILINEAR)newImage.save(os.path.join(outdir, os.path.basename(file)))except Exception as e:print(e)i = 0
a = 0
for file in glob.glob("G:\\00000000000000000\\*.png"):                 # 输入图片所在的目录*.pngimg = Image.open(file).convert('RGB')img.save(file)print(file)i += 1Resize(file, path, 640, 480)  # 新图片存放的目录img1 = Image.open(file)print(img1.getbands())  # ('P',) 这种是有彩色的,而L是没有彩色的print(img1.size)if len(img1.getbands()) == 3:a += 1print('图片总数量:', i)
print('总图像是RGB的数量:', a)files1 = os.listdir(path)
i1 = 0
a1 = 0
c1 = 0
for pic in files1:img = Image.open(os.path.join(path, pic))print(pic)print(img.getbands())  # ('P',) 这种是有彩色的,而L是没有彩色的print(img.size)i1 +=1# Img = np.array(img)# a = np.unique(Img)# print(a)    #看像素值if len(img.getbands()) == 3:a1 +=1size = img.sizew = size[0]  # 宽度h = size[1]  # 高度if w == 640:if h == 480:c1 += 1print('测试前处理再此确认输入图像image的总数量: ', i1)
print('测试前处理再此确认输入图像是RGB的数量:', a1)
print('测试前处理再此确认输入图像是640*480的数量:', c1)# args
parse = argparse.ArgumentParser()
parse.add_argument('--config', dest='config', type=str, default='./configs/bisenetv2_city.py',)
parse.add_argument('--weight-path', type=str, default='./v3_model_final.pth',)     # 模型路径
parse.add_argument('--img_path', dest='img_path', type=str, default=path,)         # 测试图片输入路径
args = parse.parse_args()
cfg = set_cfg_from_file(args.config)palette = np.random.randint(0, 256, (256, 3), dtype=np.uint8)# define model
net = model_factory[cfg.model_type](cfg.n_cats, aux_mode='pred')
net.load_state_dict(torch.load(args.weight_path, map_location='cpu'), strict=False)
net.eval()
# net.cuda()# prepare data
to_tensor = T.ToTensor(mean=(0.3257, 0.3690, 0.3223), # city, rgbstd=(0.2112, 0.2148, 0.2115),
)
dir_path = args.img_path
count1 = 0
count2 = 0
for file_name in tqdm(os.listdir(dir_path)):path1 = path + file_name # 这里表示输入图像的路径im = cv2.imread(path1)[:, :, ::-1]  # 主要是这里读入的路径# 后面的接着写就行# im = to_tensor(dict(im=im, lb=None))['im'].unsqueeze(0).cuda()im = to_tensor(dict(im=im, lb=None))['im'].unsqueeze(0)# inferencet1 = time.time()out = net(im).squeeze().detach().cpu().numpy()cv2.imwrite('G:\\11mask\\' + file_name, out)                      # 这里表示输出mask图像的路径def create_pascal_label_colormap():colormap = np.zeros((256, 3), dtype=int)ind = np.arange(256, dtype=int)for shift in reversed(range(8)):for channel in range(3):colormap[:, channel] |= ((ind >> channel) & 1) << shiftind >>= 3return colormapdef label_to_color_image(label):if label.ndim != 2:raise ValueError('Expect 2-D input label')colormap = create_pascal_label_colormap()if np.max(label) >= len(colormap):raise ValueError('label value too large.')return colormap[label]def vis_segmentation(image, seg_map):"""输入图片和分割 mask 的可视化."""plt.figure(figsize=(15, 5))grid_spec = gridspec.GridSpec(1, 4, width_ratios=[6, 6, 6, 1])plt.subplot(grid_spec[0])plt.imshow(image)plt.axis('off')plt.title('input image')plt.subplot(grid_spec[1])seg_image = label_to_color_image(seg_map).astype(np.uint8)plt.imshow(seg_image)plt.axis('off')plt.title('segmentation map')plt.subplot(grid_spec[2])plt.imshow(image)plt.imshow(seg_image, alpha=0.7)plt.axis('off')plt.title('segmentation overlay')unique_labels = np.unique(seg_map)ax = plt.subplot(grid_spec[3])plt.imshow(FULL_COLOR_MAP[unique_labels].astype(np.uint8), interpolation='nearest')ax.yaxis.tick_right()plt.yticks(range(len(unique_labels)), LABEL_NAMES[unique_labels])plt.xticks([], [])ax.tick_params(width=0.0)plt.grid('off')# plt.show()LABEL_NAMES = np.asarray(['unlabeled','road','sidewalk'])  # 假设只有三类
FULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)
FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)img_path = path  # 原图
png_path = 'G:\\11mask\\'                                          # mask图(全黑)
v = 0
for img in tqdm(os.listdir(img_path)):# print(img)imgfile = img_path + imgpngfile = png_path + imgnew_path = 'G:\\pltsave\\' + img                               # 可视化测试结果路径img = cv2.imread(imgfile, 1)img = img[:, :, ::-1]seg_map = cv2.imread(pngfile, 0)vis_segmentation(img, seg_map)plt.savefig(new_path)plt.close()v += 1# plt.clf()print('Done!!!!测试集测试完毕并可视化数量:', v)

输出结果如下:



也可以参考分布式处理(不推荐):

import os
import glob
import os.path
from PIL import Image
from PIL import ImageFile        #批量修改尺寸2048*1024(此时也可能32位)
ImageFile.LOAD_TRUNCATED_IMAGES = Truepath = "G:\\000\\image_ground150"
files = os.listdir(path)          #会按顺序排列1,2,3,4,.png格式
i=0
for file in files:original = path + os.sep+ files[i]new = path + os.sep + str(i+1) + ".png"os.rename(original,new)i +=1
def Resize(file, outdir, width, height):imgFile = Image.open(file)try:newImage = imgFile.resize((width, height), Image.BILINEAR)newImage.save(os.path.join(outdir, os.path.basename(file)))except Exception as e:print(e)i = 0
a = 0
for file in glob.glob("G:\\000\\image_ground150\\*.png"): # 图片所在的目录img = Image.open(file).convert('RGB')print(file)i += 1Resize(file, path, 640, 480)  # 新图片存放的目录img1 = Image.open(file)print(img1.getbands())  # ('P',) 这种是有彩色的,而L是没有彩色的print(img1.size)if len(img1.getbands()) == 3:a +=1
print('图片总数量:', i)
print('总图像是RGB的数量:', a)

检查下是否转化成功:

import os.path
from PIL import Image
from PIL import ImageFile        #批量修改尺寸2048*1024(此时也可能32位)
ImageFile.LOAD_TRUNCATED_IMAGES = True
import cv2path = "G:\\000\\image_ground150\\"files = os.listdir(path)
print(files)
i = 0
a = 0
c = 0
for pic in files:img = Image.open(os.path.join(path, pic))print(pic)print(img.getbands())  # ('P',) 这种是有彩色的,而L是没有彩色的print(img.size)i +=1# Img = np.array(img)# a = np.unique(Img)# print(a)    #看像素值if len(img.getbands()) == 3:a +=1size = img.sizew = size[0]  # 宽度h = size[1]  # 高度if w == 640:if h == 480:c += 1print('图像image的总数量: ', i)
print('总图像是RGB的数量:', a)
print('总图像是640*480的数量:', c)

3.demo.py进行测试生成全黑mask

import sys
sys.path.append("..")
sys.path.insert(0, '.')
import argparse
import torch
import torch.nn as nn
from PIL import Image
import numpy as np
import cv2
import time
import os #要导入osimport lib.transform_cv2 as T
from lib.models import model_factory
from configs import set_cfg_from_filefrom tqdm import tqdmtorch.set_grad_enabled(False)
np.random.seed(123)# args
parse = argparse.ArgumentParser()
parse.add_argument('--config', dest='config', type=str, default='./configs/bisenetv2_city.py',)
parse.add_argument('--weight-path', type=str, default='./v3_model_final.pth',)
parse.add_argument('--img_path', dest='img_path', type=str, default='G:\\0907ground_test\\20210906_images\\',)
args = parse.parse_args()
cfg = set_cfg_from_file(args.config)palette = np.random.randint(0, 256, (256, 3), dtype=np.uint8)# define model
net = model_factory[cfg.model_type](cfg.n_cats, aux_mode='pred')
net.load_state_dict(torch.load(args.weight_path, map_location='cpu'), strict=False)
net.eval()
# net.cuda()# prepare data
to_tensor = T.ToTensor(mean=(0.3257, 0.3690, 0.3223), # city, rgbstd=(0.2112, 0.2148, 0.2115),
)
dir_path = args.img_path
count1 = 0
count2 = 0
for file_name in tqdm(os.listdir(dir_path)):path = 'G:\\0907ground_test\\20210906_images\\' + file_name # 这里表示输入图像的路径im = cv2.imread(path)[:, :, ::-1]  # 主要是这里读入的路径# 后面的接着写就行# im = to_tensor(dict(im=im, lb=None))['im'].unsqueeze(0).cuda()im = to_tensor(dict(im=im, lb=None))['im'].unsqueeze(0)# inferencet1 = time.time()out = net(im).squeeze().detach().cpu().numpy()# if out.__contains__(1):#     count1 += 1#     pred = palette[out]# if np.count_nonzero(out > 0) > 24576:#     count1 += 1#     pred = palette[out]#     cv2.imwrite('G:\\000\\ground_8%\\' + file_name, pred)## if np.count_nonzero(out > 0) > 15300:#     count2 += 1#     pred = palette[out]#     cv2.imwrite('G:\\000\\ground_5%\\' + file_name, pred)# pred = palette[out]cv2.imwrite('G:\\0907ground_test\\0907_v3mask\\' + file_name, out) # 这里表示输出图像的路径
# print('图像误分割大于8%个数:', count1)
# print('图像误分割大于5%的个数:', count2)# cv2.imwrite('output.jpg', pred)
# cv2.namedWindow("output", cv2.WINDOW_NORMAL)
# cv2.imshow("output", pred)
# cv2.waitKey(0)

4. 测试预测图像可视化(原图、全黑mask)

import matplotlib.pyplot as plt
from matplotlib import gridspec
import numpy as np
import cv2
import osdef create_pascal_label_colormap():colormap = np.zeros((256, 3), dtype=int)ind = np.arange(256, dtype=int)for shift in reversed(range(8)):for channel in range(3):colormap[:, channel] |= ((ind >> channel) & 1) << shiftind >>= 3return colormapdef label_to_color_image(label):if label.ndim != 2:raise ValueError('Expect 2-D input label')colormap = create_pascal_label_colormap()if np.max(label) >= len(colormap):raise ValueError('label value too large.')return colormap[label]def vis_segmentation(image, seg_map):"""输入图片和分割 mask 的可视化."""plt.figure(figsize=(15, 5))grid_spec = gridspec.GridSpec(1, 4, width_ratios=[6, 6, 6, 1])plt.subplot(grid_spec[0])plt.imshow(image)plt.axis('off')plt.title('input image')plt.subplot(grid_spec[1])seg_image = label_to_color_image(seg_map).astype(np.uint8)plt.imshow(seg_image)plt.axis('off')plt.title('segmentation map')plt.subplot(grid_spec[2])plt.imshow(image)plt.imshow(seg_image, alpha=0.7)plt.axis('off')plt.title('segmentation overlay')unique_labels = np.unique(seg_map)ax = plt.subplot(grid_spec[3])plt.imshow(FULL_COLOR_MAP[unique_labels].astype(np.uint8), interpolation='nearest')ax.yaxis.tick_right()plt.yticks(range(len(unique_labels)), LABEL_NAMES[unique_labels])plt.xticks([], [])ax.tick_params(width=0.0)plt.grid('off')# plt.savefig("G:\\0907ground_test\\plt\\" + image)# plt.show()LABEL_NAMES = np.asarray(['unlabeled','road','sidewalk'])  # 假设只有三类
FULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)
FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)img_path = 'G:\\0907ground_test\\20210906_images\\'  # 原图
png_path = 'G:\\0907ground_test\\0907_v3mask\\'     # mask图(全黑)
for img in os.listdir(img_path):print(img)imgfile = img_path + imgpngfile = png_path + img
# imgfile = 'G:\\0907ground_test\\20210906_images\\108.png'
# pngfile = 'G:\\0907ground_test\\0907_v3mask\\108.png'new_path = 'G:\\0907ground_test\\plt\\' + imgimg = cv2.imread(imgfile, 1)img = img[:, :, ::-1]seg_map = cv2.imread(pngfile, 0)vis_segmentation(img, seg_map)plt.savefig(new_path)plt.close()# plt.clf()print('Done.')

1. 验证集 -- 批量测试和可视化 2. 测试集 -- 批量测试和可视化相关推荐

  1. ubuntu16.04下使用YOLOV3训练自己做的VOC数据集(VOC数据集制作+模型训练步骤+训练参数解析和问题解决+训练日志可视化(loss、IOU)+模型测试(单张、摄像头、批量测试))

    前序 1.环境配置 请自行参考其他博客 本机环境 ubuntu16.04 python3 英伟达显卡驱动:nvidia-396 OpenCV3.4.5 CUDNN7.0.5 CUDA9.0 2.ubu ...

  2. python可视化多个机器学习模型在独立测试集(test data set)上面的AUC值、可视化模型效能

    python可视化多个机器学习模型在独立测试集(test data set)上面的AUC值.可视化模型效能 # x_lables为模型名称列表,包括,逻辑回归.朴素贝叶斯.支持向量机.随机森林.xgb ...

  3. 为什么引入验证集来评估机器学习模型?只用训练集和测试集可以吗?

    评估模型的重点是将数据划分为三个集合:训练集.验证集和测试集.在训练数据上训练模型,在验证数据上评估模型.一旦找到了最佳参数,就在测试数据上最后测试一次.你可能会问,为什么不是两个集合:一个训练集和一 ...

  4. 故障转移集群无法连接到节点_Redis集群以及自动故障转移测试

    在Redis中,与Sentinel(哨兵)实现的高可用相比,集群(cluster)更多的是强调数据的分片或者是节点的伸缩性,如果在集群的主节点上加入对应的从节点,集群还可以自动故障转移,因此相比Sen ...

  5. weka使用训练集分类测试集_Giao 13C NMR计算分类训练集提高结构归属的准确性和可靠性...

    Giao 13C NMR计算分类训练集提高结构归属的准确性和可靠性 前言 GIAO 13C NMR计算对于小分子结构归属有很重要的作用,尤其对于需要提高准确性和可信性的复杂有机分子的结构归属.准确度是 ...

  6. 面经合集(包含python、mysql、linux、测试等内容)

    mysql 1. 怎么排序? order by. 2. 聚合函数 sum,count,min,max... 3. 介绍一下mysql 关系型数据库.由于体积小.速度快.成本低.开源,MySQL被广泛的 ...

  7. 6759字25个APP测试流程以及资料合集【乐搏TestPro】

    App测试流程及资料合集 / 1 / 测试理论知识:跟其他web等测试一样: 如果基础不够建议先看书:给软件测试从业者推荐6本书籍 / 2 / 整体测试流程:同web类似 具体差异化见下方内容 / 3 ...

  8. 渗透测试 ( 5 ) --- 扫描之王 nmap、渗透测试工具实战技巧合集

    Nmap 官方文档 ( 中文文档是 Nmap 版本4.50,英文文档是最新的 ): 英文文档:https://nmap.org/book/man.html 中文文档:https://nmap.org/ ...

  9. linux磁盘fio压力测试,fio命令 – 对磁盘进行压力测试和验证

    fio是测试IOPS的非常好的工具,用来对磁盘进行压力测试和验证.磁盘IO是检查磁盘性能的重要指标,可以按照负载情况分成照顺序读写,随机读写两大类.FIO是一个可以产生很多线程或进程并执行用户指定的特 ...

  10. Echarts+D3可视化开发工具集

    Echarts+D3可视化开发工具集 一.前言 ​ 大学三年期间,学的很杂,但唯一坚持的就是在做可视化开发,有个负责任的指导老师很重要.因为即将大四,之后不一定会再继续朝这个方面学习,所以把之前参加比 ...

最新文章

  1. 使用Ranger对Hive数据进行脱敏
  2. PHP警告:socket_bind():无法绑定地址
  3. Django的View(视图)
  4. C和指针之函数之把数字字符串转为整数并且返回这个数字(ascii_to_integer)
  5. 【洛谷】P1641 [SCOI2010]生成字符串(思维+组合+逆元)
  6. linux系统核心已存储,Linux系统 存储
  7. idea server日志乱码_windows下,Kiwi_Syslog日志服务器的搭建
  8. spring思想分析
  9. LeetCode84 Largest Rectangle in Histogram
  10. Linux的环境变量.bash_profile .bashrc profile文件
  11. 颜色直方图的计算、显示、处理、对比及反向投影(How to Use Histogram? Calculate, Show, Process, Compare and BackProject)...
  12. 昨天晚上全新打造N无线AP
  13. 《JAVA 技术》第二次作业
  14. 你的才艺怎样变现?--Rarible平台
  15. php 通过API接口连接12306余票查询
  16. 【转】一起做RGB-D SLAM (1)
  17. ds12c887程序C语言,时钟芯片DS12C887使用说明详解.doc
  18. 脑洞文之去火星搞IT!
  19. 关于BeanUtils.populate()方法使用时的报错解决
  20. 猿大师播放器有哪些不同的版本,分别适合哪些不同需求的场景?

热门文章

  1. .NET读写Excel工具Spire.Xls使用(1)入门介绍
  2. protel DXP的类矢量图功能
  3. Android之ksoap2-android详解与调用天气预报Webservice完整实例
  4. 自定义注解妙用,一行代码搞定用户操作日志记录,你学会了吗?
  5. 系统架构设计:平滑发布和ABTesting
  6. 一次深夜优化,MySQL亿级数据分页的奇妙经历
  7. 谷歌员工论坛自述引程序员羡慕,只招募最优秀的人,薪资福利超棒
  8. Java问题排查工具清单
  9. 源码资本深耕“三横九纵”科技助力网聚优秀企业
  10. Windows 10安装Tensorflow