Skip to content
Snippets Groups Projects
Commit 6f0d4255 authored by Frisinghelli Daniel's avatar Frisinghelli Daniel
Browse files

Plotting samples for presentation

parent 6c3c00d5
No related branches found
No related tags found
No related merge requests found
......@@ -124,7 +124,7 @@ plot_samples = True
# number of samples to plot
# if nsamples = -1, all samples are plotted
nsamples = 10
nsamples = 50
# plot_bands defines the bands used to plot a false color composite of the
# input scene: red = bands[0], green = bands[1], blue = bands[2]
......
# builtins
import os
import sys
# externals
......@@ -20,17 +21,18 @@ if __name__ == '__main__':
cm, accuracy, loss = trainer.predict(state_path, state_file,
confusion=True)
# calculate overal accuracy
# # calculate overal accuracy
acc = (cm.diag().sum() / cm.sum()).numpy().item()
print('After training for {:d} epochs, we achieved an overall accuracy of '
'{:.2f}% on the validation set!'.format(trainer.model.epoch,
acc * 100))
# plot confusion matrix
# # plot confusion matrix
trainer.dataset.plot_confusion_matrix(cm, state=state_file)
# plot loss and accuracy
trainer.dataset.plot_loss(trainer.loss_state)
trainer.dataset.plot_loss(
os.path.join(state_path, state_file.replace('.pt', '_loss.pt')))
# whether to plot the samples of the validation dataset
if plot_samples:
......@@ -65,4 +67,5 @@ if __name__ == '__main__':
fig, ax = trainer.dataset.plot_sample(inputs, labels, y_pred,
bands=plot_bands,
state=sname,
stretch=True)
stretch=True,
alpha=5)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment