Untitled

 avatar
unknown
python
2 years ago
911 B
5
Indexable
all_psnr = []
all_dice = []
all_mse = []
all_ssim = []
for batch in testgen:
    [masked_images, masks], sample_labels = batch
    for i in range(8):
      inputs = [masked_images[i].reshape((1,)+masked_images[i].shape), masks[i].reshape((1,)+masks[i].shape)]
      impainted_image = best_model.predict(inputs)
      a = impainted_image.reshape(impainted_image.shape[1:])
      b = sample_labels[i]
      all_psnr.append(tf.image.psnr(a,b,1.0).numpy())
      all_ssim.append(tf.image.ssim(tf.convert_to_tensor(a, tf.float32),tf.convert_to_tensor(b, tf.float32),1.0).numpy())
      all_dice.append(dice_coef(tf.cast(b, tf.double),tf.cast(a, tf.double)).numpy())
      all_mse.append(np.mean(tf.keras.metrics.mean_squared_error(b,a).numpy()))

print(np.mean(all_psnr), np.std(all_psnr))
print(np.mean(all_dice), np.std(all_dice))
print(np.mean(all_mse), np.std(all_mse))
print(np.mean(all_ssim), np.std(all_ssim))
Editor is loading...