Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autosimilarity_segmentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MARMORET Axel
autosimilarity_segmentation
Commits
afdb83c4
Commit
afdb83c4
authored
1 year ago
by
MARMORET Axel
Browse files
Options
Downloads
Patches
Plain Diff
Current plot to common plot
parent
3d1c99ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
as_seg/model/common_plot.py
+75
-0
75 additions, 0 deletions
as_seg/model/common_plot.py
with
75 additions
and
0 deletions
as_seg/model/c
urrent
_plot.py
→
as_seg/model/c
ommon
_plot.py
+
75
−
0
View file @
afdb83c4
...
...
@@ -5,46 +5,15 @@ Created on Fri Feb 22 16:29:17 2019
@author: amarmore
Defining common plotting functions.
NB: This module
'
s name actually comes from an incorrect translation
from the french
"
courant
"
into
"
current
"
, instead of
"
common
"
.
Please excuse me for this translation.
"""
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.cm
as
cm
# %% Plotting utils
def
plot_me_this_spectrogram
(
spec
,
title
=
"
Spectrogram
"
,
x_axis
=
"
x_axis
"
,
y_axis
=
"
y_axis
"
,
invert_y_axis
=
True
,
cmap
=
cm
.
Greys
,
figsize
=
None
,
norm
=
None
,
vmin
=
None
,
vmax
=
None
):
"""
Plots a spectrogram in a colormesh.
"""
if
figsize
!=
None
:
plt
.
figure
(
figsize
=
figsize
)
elif
spec
.
shape
[
0
]
==
spec
.
shape
[
1
]:
plt
.
figure
(
figsize
=
(
7
,
7
))
padded_spec
=
spec
#pad_factor(spec)
plt
.
pcolormesh
(
np
.
arange
(
padded_spec
.
shape
[
1
]),
np
.
arange
(
padded_spec
.
shape
[
0
]),
padded_spec
,
cmap
=
cmap
,
norm
=
norm
,
vmin
=
vmin
,
vmax
=
vmax
,
shading
=
'
auto
'
)
plt
.
title
(
title
)
plt
.
xlabel
(
x_axis
)
plt
.
ylabel
(
y_axis
)
if
invert_y_axis
:
plt
.
gca
().
invert_yaxis
()
plt
.
show
()
def
pad_factor
(
factor
):
"""
Pads the factor with zeroes on both dimension.
This is made because colormesh plots values as intervals (post and intervals problem),
and so discards the last value.
"""
padded
=
np
.
zeros
((
factor
.
shape
[
0
]
+
1
,
factor
.
shape
[
1
]
+
1
))
for
i
in
range
(
factor
.
shape
[
0
]):
for
j
in
range
(
factor
.
shape
[
1
]):
padded
[
i
,
j
]
=
factor
[
i
,
j
]
return
np
.
array
(
padded
)
from
base_audio.common_plot
import
*
# %% Plotting utils
def
plot_lenghts_hist
(
lengths
):
"""
Plots the lengths of segments in an histogram
...
...
@@ -94,54 +63,6 @@ def plot_measure_with_annotations_and_prediction(measure, annotations, frontiers
plt
.
plot
([
x
,
x
],
[
0
,
np
.
amax
(
measure
)],
'
-
'
,
linewidth
=
1
,
color
=
"
orange
"
)
plt
.
show
()
def
plot_spec_with_annotations
(
factor
,
annotations
,
color
=
"
yellow
"
,
title
=
None
):
"""
Plots a spectrogram with the segmentation annotation.
"""
if
factor
.
shape
[
0
]
==
factor
.
shape
[
1
]:
plt
.
figure
(
figsize
=
(
7
,
7
))
plt
.
title
(
title
)
padded_fac
=
pad_factor
(
factor
)
plt
.
pcolormesh
(
np
.
arange
(
padded_fac
.
shape
[
1
]),
np
.
arange
(
padded_fac
.
shape
[
0
]),
padded_fac
,
cmap
=
cm
.
Greys
)
plt
.
gca
().
invert_yaxis
()
for
x
in
annotations
:
plt
.
plot
([
x
,
x
],
[
0
,
len
(
factor
)],
'
-
'
,
linewidth
=
1
,
color
=
color
)
plt
.
show
()
def
plot_spec_with_annotations_abs_ord
(
factor
,
annotations
,
color
=
"
green
"
,
title
=
None
,
cmap
=
cm
.
gray
):
"""
Plots a spectrogram with the segmentation annotation in both x and y axes.
"""
if
factor
.
shape
[
0
]
==
factor
.
shape
[
1
]:
plt
.
figure
(
figsize
=
(
7
,
7
))
plt
.
title
(
title
)
padded_fac
=
pad_factor
(
factor
)
plt
.
pcolormesh
(
np
.
arange
(
padded_fac
.
shape
[
1
]),
np
.
arange
(
padded_fac
.
shape
[
0
]),
padded_fac
,
cmap
=
cmap
)
plt
.
gca
().
invert_yaxis
()
for
x
in
annotations
:
plt
.
plot
([
x
,
x
],
[
0
,
len
(
factor
)],
'
-
'
,
linewidth
=
1
,
color
=
color
)
plt
.
plot
([
0
,
len
(
factor
)],
[
x
,
x
],
'
-
'
,
linewidth
=
1
,
color
=
color
)
plt
.
show
()
def
plot_spec_with_annotations_and_prediction
(
factor
,
annotations
,
predicted_ends
,
title
=
"
Title
"
):
"""
Plots a spectrogram with the segmentation annotation and the estimated segmentation.
"""
if
factor
.
shape
[
0
]
==
factor
.
shape
[
1
]:
plt
.
figure
(
figsize
=
(
7
,
7
))
plt
.
title
(
title
)
padded_fac
=
pad_factor
(
factor
)
plt
.
pcolormesh
(
np
.
arange
(
padded_fac
.
shape
[
1
]),
np
.
arange
(
padded_fac
.
shape
[
0
]),
padded_fac
,
cmap
=
cm
.
Greys
)
plt
.
gca
().
invert_yaxis
()
for
x
in
annotations
:
plt
.
plot
([
x
,
x
],
[
0
,
len
(
factor
)],
'
-
'
,
linewidth
=
1
,
color
=
"
#8080FF
"
)
for
x
in
predicted_ends
:
if
x
in
annotations
:
plt
.
plot
([
x
,
x
],
[
0
,
len
(
factor
)],
'
-
'
,
linewidth
=
1
,
color
=
"
green
"
)
#"#17becf")
else
:
plt
.
plot
([
x
,
x
],
[
0
,
len
(
factor
)],
'
-
'
,
linewidth
=
1
,
color
=
"
orange
"
)
plt
.
show
()
def
plot_segments_with_annotations
(
seg
,
annot
):
"""
Plots the estimated labelling of segments next to with the frontiers in the annotation.
...
...
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