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
34de2a32
Commit
34de2a32
authored
11 months ago
by
Stephane Chavin
Browse files
Options
Downloads
Patches
Plain Diff
correct get_time_freq
parent
ddc96b55
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
get_time_freq_detection.py
+7
-4
7 additions, 4 deletions
get_time_freq_detection.py
utils.py
+10
-8
10 additions, 8 deletions
utils.py
with
17 additions
and
12 deletions
get_time_freq_detection.py
+
7
−
4
View file @
34de2a32
...
...
@@ -20,7 +20,7 @@ def main(arguments):
df
,
dir_path
=
utils
.
detection2time_freq
(
annotations_folder
=
arguments
.
path_to_data
,
duration
=
arguments
.
duration
,
outdir
=
arguments
.
directory
,
s
r
=
arguments
.
s
r
,
r
f
=
arguments
.
r
f
,
names
=
names
,
wav
=
args
.
path_to_wav
,
raven
=
args
.
raven
)
...
...
@@ -35,7 +35,10 @@ def main(arguments):
'"
begin time (s)
"
;
"
end time (s)
"
and the species detected
'
'
in the given files.
'
)
ds
.
attrs
[
'
date_created
'
]
=
pd
.
Timestamp
.
now
().
isoformat
()
try
:
ds
.
attrs
[
'
creator_name
'
]
=
os
.
getlogin
()
except
Exception
:
ds
.
attrs
[
'
creator_name
'
]
=
input
(
'
Your name :
'
)
# Save Dataset to NetCDF file
ds
.
to_netcdf
(
dir_path
)
...
...
@@ -51,8 +54,8 @@ if __name__ == "__main__":
help
=
'
Directory where the dataframe will be stored
'
)
parser
.
add_argument
(
'
names
'
,
type
=
str
,
help
=
'
path to YOLOv5 custom_data.yaml file
'
)
parser
.
add_argument
(
'
-
s
'
,
'
--sr
'
,
type
=
int
,
help
=
'
S
ampl
ing Rate of the spectrogram
'
,
required
=
True
)
parser
.
add_argument
(
'
-
-rf
'
,
type
=
int
,
help
=
'
Res
ampl
e frequency
'
,
required
=
True
)
parser
.
add_argument
(
'
--duration
'
,
type
=
int
,
help
=
'
Duration of the spectrogram
'
,
default
=
8
)
parser
.
add_argument
(
'
--path_to_wav
'
,
type
=
utils
.
arg_directory
,
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
10
−
8
View file @
34de2a32
...
...
@@ -355,17 +355,19 @@ def prepare_dataframe(df, args):
return
df
,
species_list
def
detection2time_freq
(
annotations_folder
,
duration
,
outdir
,
s
r
,
names
,
wav
,
raven
):
def
detection2time_freq
(
annotations_folder
,
duration
,
outdir
,
r
f
,
names
,
wav
,
raven
):
"""
Collect all .txt detection and get time and frequency informations
:param annotations_folder (str): Path to the .
json
files
:param annotations_folder (str): Path to the .
txt
files
:param duration (int): Directory to save the .txt files
:param outfir (str): Directory to save the .txt files
:param sr (int): Directory to save the .txt files
:param names (str): Directory to save the .txt files
:param outdir (str): Directory to save the .txt files
:param rf (int): Resampling freq.
:param names (str): names of the classes
:param wav (str): Path to the wav
:param raven (int): Save into Raven format or not
"""
today
=
date
.
today
()
out_file
=
f
'
YOLO_detection_
{
today
.
day
}
_
{
today
.
month
}
_freq_
{
s
r
}
_duration_
{
duration
}
.nc
'
out_file
=
f
'
YOLO_detection_
{
today
.
day
}
_
{
today
.
month
}
_freq_
{
r
f
}
_duration_
{
duration
}
.nc
'
# Load and process data
df
=
pd
.
concat
({
f
:
pd
.
read_csv
(
os
.
path
.
join
(
annotations_folder
,
f
),
...
...
@@ -390,8 +392,8 @@ def detection2time_freq(annotations_folder, duration, outdir, sr, names, wav, ra
df
[
'
species
'
]
=
df
[
'
class
'
].
apply
(
lambda
x
:
names
[
int
(
x
)])
df
[
'
pos
'
]
=
(
df
[
'
x
'
]
*
duration
)
+
df
[
'
class
'
].
astype
(
int
)
df
[
'
Low Freq (Hz)
'
]
=
(
1
-
df
[
'
y
'
])
*
(
s
r
/
2
)
-
(
df
[
'
h
'
]
*
(
s
r
/
2
))
/
2
df
[
'
High Freq (Hz)
'
]
=
(
1
-
df
[
'
y
'
])
*
(
s
r
/
2
)
+
(
df
[
'
h
'
]
*
(
s
r
/
2
))
/
2
df
[
'
Low Freq (Hz)
'
]
=
(
1
-
df
[
'
y
'
])
*
(
r
f
/
2
)
-
(
df
[
'
h
'
]
*
(
r
f
/
2
))
/
2
df
[
'
High Freq (Hz)
'
]
=
(
1
-
df
[
'
y
'
])
*
(
r
f
/
2
)
+
(
df
[
'
h
'
]
*
(
r
f
/
2
))
/
2
df
[
'
Begin Time (s)
'
]
=
df
[
'
pos
'
]
-
(
df
[
'
w
'
]
*
duration
)
/
2
df
[
'
End Time (s)
'
]
=
df
[
'
pos
'
]
+
(
df
[
'
w
'
]
*
duration
)
/
2
df
[
'
duration
'
]
=
df
[
'
End Time (s)
'
]
-
df
[
'
Begin Time (s)
'
]
...
...
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