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
615e80ea
Commit
615e80ea
authored
Jan 25, 2023
by
Stephane Chavin
Browse files
Options
Downloads
Patches
Plain Diff
add script
parent
bf80eed5
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
get_time_detection.py
+117
-0
117 additions, 0 deletions
get_time_detection.py
with
117 additions
and
0 deletions
get_time_detection.py
0 → 100644
+
117
−
0
View file @
615e80ea
import
pandas
as
pd
import
os
import
ipdb
from
tqdm
import
tqdm
import
argparse
from
datetime
import
date
def
arg_directory
(
path
):
if
os
.
path
.
isdir
(
path
):
return
path
else
:
raise
argparse
.
ArgumentTypeError
(
f
'
`
{
path
}
` is not a valid path
'
)
parser
=
argparse
.
ArgumentParser
(
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
description
=
'
TODO
'
)
parser
.
add_argument
(
'
-p
'
,
'
--path_to_data
'
,
type
=
arg_directory
,
help
=
'
Path of the folder that contain the .txt files
'
,
required
=
True
)
parser
.
add_argument
(
'
-d
'
,
'
--direction
'
,
type
=
arg_directory
,
help
=
'
Directory to wich the dataframe will be stored
'
,
required
=
True
)
args
=
parser
.
parse_args
()
annots
=
args
.
path_to_data
today
=
date
.
today
()
out_file
=
str
(
'
YOLO_detection_
'
+
str
(
'
_
'
+
today
.
day
+
'
_
'
+
today
.
month
))
outdir
=
args
.
direction
df
=
pd
.
DataFrame
(
columns
=
[
'
file
'
,
'
idx
'
,
'
espece
'
,
'
x
'
,
'
y
'
,
'
w
'
,
'
h
'
,
'
conf
'
])
for
i
in
tqdm
(
os
.
listdir
(
annots
)):
if
i
==
'
list_results_YOLO.csv
'
:
continue
else
:
table
=
pd
.
read_csv
(
str
(
annots
+
i
),
sep
=
'
'
)
l
=
[]
tab
=
pd
.
DataFrame
(
columns
=
[
'
file
'
,
'
idx
'
,
'
espece
'
,
'
x
'
,
'
y
'
,
'
w
'
,
'
h
'
,
'
conf
'
])
tab2
=
pd
.
DataFrame
(
columns
=
[
'
file
'
,
'
idx
'
,
'
espece
'
,
'
x
'
,
'
y
'
,
'
w
'
,
'
h
'
,
'
conf
'
])
if
len
(
table
)
==
0
:
for
j
in
table
.
columns
:
l
.
append
(
j
)
name
=
i
.
split
(
'
.
'
)[
0
]
if
len
(
name
.
split
(
'
_
'
)[
-
1
])
==
2
:
name
=
name
.
split
(
'
.
'
)[
0
][
0
:
-
3
]
elif
len
(
name
.
split
(
'
_
'
)[
-
1
])
==
3
:
name
=
name
.
split
(
'
.
'
)[
0
][
0
:
-
4
]
else
:
name
=
name
.
split
(
'
.
'
)[
0
][
0
:
-
2
]
name
=
str
(
name
+
'
.wav
'
)
idx
=
i
.
split
(
'
_
'
)[
-
1
]
idx
=
idx
.
split
(
'
.
'
)[
0
]
table
=
pd
.
DataFrame
([[
name
,
idx
,
l
[
0
],
l
[
1
],
l
[
2
],
l
[
3
],
l
[
4
],
l
[
5
]]],
columns
=
[
'
file
'
,
'
idx
'
,
'
espece
'
,
'
x
'
,
'
y
'
,
'
w
'
,
'
h
'
,
'
conf
'
])
df
=
pd
.
concat
([
df
,
table
])
else
:
nb
=
len
(
table
)
name
=
i
.
split
(
'
.
'
)[
0
]
if
len
(
name
.
split
(
'
_
'
)[
-
1
])
==
2
:
name
=
name
.
split
(
'
.
'
)[
0
][
0
:
-
3
]
elif
len
(
name
.
split
(
'
_
'
)[
-
1
])
==
3
:
name
=
name
.
split
(
'
.
'
)[
0
][
0
:
-
4
]
else
:
name
=
name
.
split
(
'
.
'
)[
0
][
0
:
-
2
]
name
=
str
(
name
+
'
.wav
'
)
idx
=
i
.
split
(
'
_
'
)[
-
1
]
idx
=
idx
.
split
(
'
.
'
)[
0
]
for
j
in
table
.
columns
:
l
.
append
(
j
)
try
:
tab2
=
pd
.
DataFrame
([[
name
,
idx
,
l
[
0
],
l
[
1
],
l
[
2
],
l
[
3
],
l
[
4
],
l
[
5
]]],
columns
=
[
'
file
'
,
'
idx
'
,
'
espece
'
,
'
x
'
,
'
y
'
,
'
w
'
,
'
h
'
,
'
conf
'
])
except
:
ipdb
.
set_trace
()
for
v
in
range
(
nb
):
new
=
pd
.
DataFrame
([[
name
,
idx
,
table
.
iloc
[
v
][
0
],
table
.
iloc
[
v
][
1
],
table
.
iloc
[
v
][
2
],
table
.
iloc
[
v
][
3
],
table
.
iloc
[
v
][
4
],
table
.
iloc
[
v
][
5
]]],
columns
=
[
'
file
'
,
'
idx
'
,
'
espece
'
,
'
x
'
,
'
y
'
,
'
w
'
,
'
h
'
,
'
conf
'
])
tab
=
pd
.
concat
([
tab
,
new
])
table
=
pd
.
concat
([
tab2
,
tab
])
df
=
pd
.
concat
([
df
,
table
])
#put the classes here
names
=
[]
df
[
'
annot
'
]
=
'
None
'
for
j
in
range
(
len
(
df
)):
df
[
'
annot
'
].
iloc
[
j
]
=
names
[
int
(
df
.
espece
.
iloc
[
j
])]
print
(
'
Calculating the positions
'
,
'
\n
'
)
corres
=
pd
.
DataFrame
(
columns
=
[
'
start
'
,
'
stop
'
])
new
=
pd
.
DataFrame
([[
'
0
'
,
'
8
'
]],
columns
=
[
'
start
'
,
'
stop
'
])
corres
=
pd
.
concat
([
corres
,
new
])
new
=
pd
.
DataFrame
([[
'
6
'
,
'
14
'
]],
columns
=
[
'
start
'
,
'
stop
'
])
corres
=
pd
.
concat
([
corres
,
new
])
DUREE_SPECTRO
=
8
OVERLAP
=
2
for
k
in
range
(
50
):
val
=
k
+
1
new
=
pd
.
DataFrame
([[
int
(
corres
.
start
.
iloc
[
val
])
+
(
DUREE_SPECTRO
-
OVERLAP
),
int
(
corres
.
stop
.
iloc
[
val
])
+
(
DUREE_SPECTRO
-
OVERLAP
)]],
columns
=
[
'
start
'
,
'
stop
'
])
corres
=
pd
.
concat
([
corres
,
new
])
df
[
'
midl
'
]
=
'
None
'
for
w
in
range
(
len
(
df
.
midl
)):
if
int
(
df
.
idx
.
iloc
[
w
])
==
0
:
try
:
df
.
midl
.
iloc
[
w
]
=
float
(
df
.
x
.
iloc
[
w
])
*
DUREE_SPECTRO
+
float
(
corres
.
start
.
iloc
[
int
(
df
.
idx
.
iloc
[
w
])])
except
:
ipdb
.
set_trace
()
else
:
df
.
midl
.
iloc
[
w
]
=
float
(
df
.
x
.
iloc
[
w
])
*
DUREE_SPECTRO
+
float
(
corres
.
start
.
iloc
[
int
(
df
.
idx
.
iloc
[
w
])])
\ No newline at end of file
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