Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySegCNN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
earth_observation_public
PySegCNN
Commits
9e8bf5d7
Commit
9e8bf5d7
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Fixed a bug: plots of loss and confusion matrix were overwritten: same filename.
parent
63b1485b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pysegcnn/core/graphics.py
+7
-5
7 additions, 5 deletions
pysegcnn/core/graphics.py
pysegcnn/main/eval.py
+1
-1
1 addition, 1 deletion
pysegcnn/main/eval.py
with
8 additions
and
6 deletions
pysegcnn/core/graphics.py
+
7
−
5
View file @
9e8bf5d7
...
...
@@ -193,7 +193,7 @@ def plot_sample(x, use_bands, labels, y=None, y_pred=None, figsize=(10, 10),
def
plot_confusion_matrix
(
cm
,
labels
,
normalize
=
True
,
figsize
=
(
10
,
10
),
cmap
=
'
Blues
'
,
state
=
None
,
figsize
=
(
10
,
10
),
cmap
=
'
Blues
'
,
state
_file
=
None
,
outpath
=
os
.
path
.
join
(
HERE
,
'
_graphics/
'
)):
"""
Plot the confusion matrix ``cm``.
...
...
@@ -214,7 +214,7 @@ def plot_confusion_matrix(cm, labels, normalize=True,
The figure size in centimeters. The default is (10, 10).
cmap : `str`, optional
A colormap in `matplotlib.pyplot.colormaps()`. The default is
'
Blues
'
.
state : `str` or `None`, optional
state
_file
: `str` or `None`
or `pathlib.Path`
, optional
Filename to save the plot to. ``state`` should be an existing model
state file ending with
'
.pt
'
. The default is None, i.e. plot is not
saved to disk.
...
...
@@ -286,9 +286,11 @@ def plot_confusion_matrix(cm, labels, normalize=True,
fig
.
colorbar
(
im
,
cax
=
cax
)
# save figure
if
state
is
not
None
:
if
state
_file
is
not
None
:
os
.
makedirs
(
outpath
,
exist_ok
=
True
)
fig
.
savefig
(
os
.
path
.
join
(
outpath
,
state
),
dpi
=
300
,
bbox_inches
=
'
tight
'
)
fig
.
savefig
(
os
.
path
.
join
(
outpath
,
os
.
path
.
basename
(
state_file
).
replace
(
'
.pt
'
,
'
_cm.png
'
)),
dpi
=
300
,
bbox_inches
=
'
tight
'
)
return
fig
,
ax
...
...
@@ -387,7 +389,7 @@ def plot_loss(state_file, figsize=(10, 10), step=5,
# save figure
os
.
makedirs
(
outpath
,
exist_ok
=
True
)
fig
.
savefig
(
os
.
path
.
join
(
outpath
,
os
.
path
.
basename
(
state_file
).
replace
(
'
.pt
'
,
'
.png
'
)),
outpath
,
os
.
path
.
basename
(
state_file
).
replace
(
'
.pt
'
,
'
_loss
.png
'
)),
dpi
=
300
,
bbox_inches
=
'
tight
'
)
return
fig
This diff is collapsed.
Click to expand it.
pysegcnn/main/eval.py
+
1
−
1
View file @
9e8bf5d7
...
...
@@ -77,5 +77,5 @@ if __name__ == '__main__':
# whether to plot the confusion matrix
if
ec
.
cm
:
plot_confusion_matrix
(
cm
,
ds
.
dataset
.
labels
,
state
=
ec
.
state_file
.
name
.
replace
(
'
.pt
'
,
'
.png
'
)
,
state
_file
=
ec
.
state_file
,
outpath
=
ec
.
perfmc_path
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment