Пример #1
0
loss_name = args.loss
poly_lr = args.poly_learning_rate
lambda_loss = args.lambda_loss
pixel_distance = args.pixel_distance

num_cl = 108
train_sz = 4498
valid_sz = 500
rsize = True

print('Model')

deeplab_model = ResNet101(input_shape_1=(None, None, 3),
                          input_shape_2=(None, None, 21),
                          classes=num_cl,
                          kernel_init=kernel_init,
                          batch_norm=batchNorm,
                          dil_rate_model=dil_rate,
                          mult_rate=mult_rate)

pathLoadWeights = "Y:/tesisti/rossi/Weights/prova.h5"
deeplab_model.load_weights(pathLoadWeights, True)

if loss_name == "standard":
    loss = ["categorical_crossentropy"]
    loss_name = "standard_loss"

elif loss_name == "custom_loss":
    loss = [custom_loss(deeplab_model.get_layer('logits'))]
    loss_name = "custom_loss"
assert not (pathCP == 'not_defined'), "Checkpoint path not defined"
if pathSave == 'not_defined':
    pathSave = "./"
else:
    pathSave = pathSave + "/"

pT = pathSave + datetime.now().strftime("%Y%m%d-%H%M%S")
print(pathCP)

if not os.path.isdir(pT):
    os.mkdir(pT)
inf_path = pT + "/inf"
os.mkdir(inf_path)

print("load model weights")
deeplab_model = ResNet101(input_shape_1=(None, None, 3), input_shape_2=(None, None, 21), classes=n_class)

deeplab_model.load_weights(pathCP, by_name=True)

dir_img = "Y:/tesisti/rossi/data/train_val_test_png/test_png/"
dir_softmax = "Y:/tesisti/rossi/data/segmentation_gray/results_softmax_deeplabV2/test/"
dir_seg = "Y:/tesisti/rossi/data/segmentation_part_gray/new_dataset_107/data_part_107part_test/"

####

images = glob.glob(dir_img + "*.png")
images.sort()
softmax = glob.glob(dir_softmax + "*.npy")
softmax.sort()
segs = glob.glob(dir_seg + "*.png")
segs.sort()