创新点:
softmax之后预测结果的形状为(b,3,208,208)
损失函数=加权的交叉熵+预测结果的实例内部方差(每通道方差求和。共3通道)
数据集:GlaS
输入:
Ternary label:inside、contours、background标记出来
Weighted map:通过matlab代码得到
test.py内容
1.定义和加载训练好的模型
# define model
model = FullNet(opt.model['in_c'], opt.model['out_c'], n_layers=opt.model['n_layers'],
growth_rate=opt.model['growth_rate'], drop_rate=opt.model['drop_rate'],
dilations=opt.model['dilations'], is_hybrid=opt.model['is_hybrid'],
compress_ratio=opt.model['compress_ratio'], layer_type=opt.model['layer_type'])
model = torch.nn.DataParallel(model).cuda()
# ----- load trained model ----- #
print("=> loading trained model")
best_checkpoint = torch.load(model_path)
model.load_state_dict(best_checkpoint['state_dict'])
print("=> loaded model at epoch {}".format(best_checkpoint['epoch']))
model = model.module
2.读入测试图像并transform,得到图像input 大小(1,3,208,208)
for img_name in img_names:
# load test image
print('=> Processing image {:s}'.format(img_name))
img_path = '{:s}/{:s}'.format(img_dir, img_name)
img = Image.open(img_path)
ori_h = img.size[1]
ori_w = img.size[0]
name = os.path.splitext(img_name)[0]
if eval_flag:
if opt.dataset == 'MultiOrgan'</