Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RAVEN2YOLO
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
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
Stephane Chavin
RAVEN2YOLO
Commits
91d5394c
Commit
91d5394c
authored
9 months ago
by
Stephane Chavin
Browse files
Options
Downloads
Patches
Plain Diff
correction dataloader and get time freq offset
parent
ae69a8db
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
get_spectrogram.py
+2
-2
2 additions, 2 deletions
get_spectrogram.py
utils.py
+7
-5
7 additions, 5 deletions
utils.py
yolov5/utils/dataloaders.py
+3
-3
3 additions, 3 deletions
yolov5/utils/dataloaders.py
with
12 additions
and
10 deletions
get_spectrogram.py
+
2
−
2
View file @
91d5394c
...
...
@@ -53,8 +53,8 @@ def main(data, arguments):
name
=
os
.
path
.
join
(
arguments
.
directory
,
folder
,
f
'
{
file
}
_
{
offset
}
'
)
utils
.
create_spectrogram
(
sig
,
arguments
.
directory
,
name
,
arguments
.
cmap
,
window_size
=
int
(
arguments
.
window
),
overlap
=
arguments
.
hop
,
vmin
=
arguments
.
vmin
)
sig
,
arguments
.
directory
,
name
,
arguments
.
cmap
,
arguments
.
vmin
,
window_size
=
int
(
arguments
.
window
),
overlap
=
arguments
.
hop
)
except
Exception
as
error
:
folder
=
'
spectrograms
'
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
7
−
5
View file @
91d5394c
...
...
@@ -87,15 +87,17 @@ def signal_processing(sig, rf, fs, high=None, low=None):
return
sig
def
create_spectrogram
(
sig
,
directory
,
names
,
cmap
,
window_size
=
1024
,
overlap
=
.
5
,
minimum
=
True
):
def
create_spectrogram
(
sig
,
directory
,
names
,
cmap
,
minimum
,
window_size
=
1024
,
overlap
=
.
5
):
"""
Create a spectrogram STFT with hanning window and save it into a directory
:param sig (array): Signal to process.
:param directory (str): Path to save the spectrogram.
:param names (str): Name of the final spectrogram.
:param cmap (str): Name of the colormap for matplotlib.
:param minimum (str): If True minimum of spectrogram imshow will be stft.mean(), else stft.min()
:param window_size (int): Number of sample / STFT window.
:param overlap (float): Ratio of overlapping samples between each window (default 50%).
:param directory (str): Path to save the spectrogram.
:param filename (str): Name of the final spectrogram.
"""
if
overlap
>=
1
:
print
(
f
'
You put a hop value over 1. This has been corrected to have
{
overlap
}
as overlap size between window
'
)
...
...
@@ -107,7 +109,7 @@ def create_spectrogram(sig, directory, names, cmap, window_size=1024, overlap=.5
hop_length
=
int
(
overlap_size
),
window
=
'
hann
'
)
# Compute the STFT
stft
=
np
.
log10
(
np
.
abs
(
stft
))
# Adapt the Complex-valued matrix
fig
=
plt
.
figure
()
if
minimum
:
if
minimum
==
'
True
'
:
vmin
=
stft
.
mean
()
else
:
vmin
=
stft
.
min
()
...
...
@@ -395,7 +397,7 @@ def detection2time_freq(annotations_folder, duration, outdir, rf, names, wav, ra
names
=
np
.
arange
(
0
,
total
+
1
).
tolist
()
df
[
'
species
'
]
=
df
[
'
class
'
].
apply
(
lambda
x
:
names
[
int
(
x
)])
df
[
'
pos
'
]
=
(
df
[
'
x
'
]
*
duration
)
+
df
[
'
class
'
].
astype
(
int
)
df
[
'
pos
'
]
=
(
df
[
'
x
'
]
*
duration
)
+
df
[
'
offset
'
].
astype
(
int
)
df
[
'
Low Freq (Hz)
'
]
=
(
1
-
df
[
'
y
'
])
*
(
rf
/
2
)
-
(
df
[
'
h
'
]
*
(
rf
/
2
))
/
2
df
[
'
High Freq (Hz)
'
]
=
(
1
-
df
[
'
y
'
])
*
(
rf
/
2
)
+
(
df
[
'
h
'
]
*
(
rf
/
2
))
/
2
df
[
'
Begin Time (s)
'
]
=
df
[
'
pos
'
]
-
(
df
[
'
w
'
]
*
duration
)
/
2
...
...
This diff is collapsed.
Click to expand it.
yolov5/utils/dataloaders.py
+
3
−
3
View file @
91d5394c
...
...
@@ -239,8 +239,8 @@ class LoadScreenshots:
return
str
(
self
.
screen
),
im
,
im0
,
None
,
s
# screen, img, original img, im0s, s
class
LoadSpectros
:
def
__init__
(
self
,
folder
,
sampleDur
,
rf
,
window
,
hop
,
low
,
high
,
cmap
,
img_size
,
stride
=
32
,
auto
=
True
,
minimum
=
True
):
self
.
folder
,
self
.
sampleDur
,
self
.
rf
,
self
.
window
,
self
.
hop
,
self
.
low
,
self
.
high
,
self
.
cmap
,
self
.
img_size
,
self
.
stride
,
self
.
auto
,
self
.
minimum
=
folder
,
sampleDur
,
rf
,
window
,
hop
,
low
,
high
,
cmap
,
img_size
,
stride
,
auto
,
minimum
def
__init__
(
self
,
folder
,
sampleDur
,
rf
,
window
,
hop
,
low
,
high
,
cmap
,
minimum
,
img_size
,
stride
=
32
,
auto
=
True
):
self
.
folder
,
self
.
sampleDur
,
self
.
rf
,
self
.
window
,
self
.
hop
,
self
.
low
,
self
.
high
,
self
.
cmap
,
self
.
minimum
,
self
.
img_size
,
self
.
stride
,
self
.
auto
=
folder
,
sampleDur
,
rf
,
window
,
hop
,
low
,
high
,
cmap
,
minimum
,
img_size
,
stride
,
auto
self
.
files
=
os
.
listdir
(
folder
)
self
.
mode
=
'
image
'
self
.
samples
=
[]
...
...
@@ -290,7 +290,7 @@ class LoadSpectros:
stft
=
librosa
.
stft
(
sig
,
n_fft
=
self
.
window
,
hop_length
=
hop
,
window
=
'
hann
'
)
# Compute the STFT
stft
=
np
.
log10
(
np
.
abs
(
stft
))
if
minimum
:
if
self
.
minimum
==
'
True
'
:
vmin
=
stft
.
mean
()
else
:
vmin
=
stft
.
min
()
...
...
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