Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
EVC
Ufv1 0
Commits
3f71a636
Commit
3f71a636
authored
Nov 23, 2025
by
valentini
Browse files
Carica un nuovo file
parent
ce775a4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Reference Software/UFV1.0-Pruning/src/utils/plot.py
0 → 100644
View file @
3f71a636
import
os
import
glob
import
pandas
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
import
argparse
def
plot_psnrs
(
batch
:
int
,
lr
:
float
,
epochs
:
int
,
plot_dir
:
str
,
metrics
:
pd
.
DataFrame
)
->
None
:
""" Plot the losses and the psnr
Input:
- batch
- lr
- epochs
aqaaa
- plot_dir
- metrics
"""
plt
.
figure
(
1
)
plt
.
plot
(
metrics
[
"mse_train"
].
values
,
label
=
"Train loss"
)
plt
.
plot
(
metrics
[
"mse_val"
].
values
,
label
=
"Valid loss"
)
plt
.
title
(
f
"Batch Size:
{
batch
}
| Learning Rate:
{
lr
}
| Epochs:
{
epochs
}
"
)
plt
.
legend
()
plt
.
savefig
(
os
.
path
.
join
(
plot_dir
,
"fig_losses.png"
))
plt
.
figure
(
2
)
plt
.
plot
(
metrics
[
"psnr_train"
].
values
,
label
=
"Train PSNR"
)
plt
.
plot
(
metrics
[
"psnr_val"
].
values
,
label
=
"Valid PSNR"
)
plt
.
title
(
f
"Batch Size:
{
batch
}
| Learning Rate:
{
lr
}
| Epochs:
{
epochs
}
"
)
plt
.
legend
()
plt
.
savefig
(
os
.
path
.
join
(
plot_dir
,
"psnr.png"
))
plt
.
close
(
"all"
)
return
None
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
(
description
=
'Plotter for csv graphs'
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'csv_file'
,
type
=
str
,
help
=
'Path to the folder where the CSV file is located'
)
parser
.
add_argument
(
'-b'
,
'--batch'
,
type
=
int
,
default
=
2
,
help
=
'Batch size of Reference'
)
# used only for legend
parser
.
add_argument
(
'-e'
,
'--epoch'
,
type
=
int
,
default
=
50
,
help
=
'Number of the training epoch '
)
# used only for legend
parser
.
add_argument
(
'--lr'
,
type
=
float
,
default
=
10e-5
,
help
=
'Learning rate of Reference'
)
# used only for legend
args
=
parser
.
parse_args
()
csv_file_paths
=
glob
.
glob
(
os
.
path
.
normpath
(
args
.
csv_file
)
+
"*/**/log.csv"
)
for
csv_file_path
in
csv_file_paths
:
print
(
"Processing: "
+
csv_file_path
)
out_dir
=
os
.
path
.
dirname
(
csv_file_path
)
data
=
pandas
.
read_csv
(
csv_file_path
)
plot_psnrs
(
args
.
batch
,
args
.
lr
,
args
.
epoch
,
out_dir
,
metrics
=
data
)
data
=
None
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment