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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephane Chavin
RAVEN2YOLO
Commits
854c810c
Commit
854c810c
authored
4 months ago
by
Stephane Chavin
Browse files
Options
Downloads
Patches
Plain Diff
add boxes correction if overflow
parent
3a2e7371
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_train_annot.py
+5
-4
5 additions, 4 deletions
get_train_annot.py
utils.py
+24
-0
24 additions, 0 deletions
utils.py
with
29 additions
and
4 deletions
get_train_annot.py
+
5
−
4
View file @
854c810c
...
...
@@ -81,10 +81,11 @@ def main(entry, arguments, species_list):
y_pxl
=
1
-
(
row
.
midl_y
/
(
arguments
.
rf
/
2
))
height_pxl
=
(
row
.
max_freq
-
row
.
min_freq
)
/
\
(
arguments
.
rf
/
2
)
# take height value in pixels
if
height_pxl
>
1
:
height_pxl
=
1
elif
height_pxl
>
y_pxl
*
2
:
y_pxl
=
y_pxl
+
0.5
*
(
height_pxl
-
y_pxl
*
2
)
# Correction if the boxes are corrupted (> 1 or < 0)
x_pxl
,
width_pxl
=
correct_box
(
x_pxl
,
width_pxl
)
y_pxl
,
height_pxl
=
correct_box
(
y_pxl
,
height_pxl
)
# Store the annotation in a DataFrame
new_table
=
pd
.
DataFrame
([[
str
(
species_list
[
species_list
.
species
==
specie
].
index
[
0
]),
x_pxl
,
y_pxl
,
width_pxl
,
height_pxl
]],
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
24
−
0
View file @
854c810c
...
...
@@ -569,3 +569,27 @@ def get_set_info(entry):
state
=
'
balanced
'
proposition
=
'
\u2705
this is good
'
return
state
,
proposition
def
correct_box
(
x
,
w
):
"""
Apply correction if there is an overflow on the annotation box
:param x (float): Ratio of the center of the box
:return w (float): Ratio of the size of the box
:return x,w (float): Corrected values
"""
# Get the beggining and the end of the box
x0
,
x1
=
(
x
-
(
w
/
2
)),
(
x
+
(
w
/
2
))
# Check the overflow
if
x1
>
1
and
x0
>
0
:
w
=
1
-
x0
x
=
x0
+
w
/
2
elif
x0
<
0
and
x1
<
1
:
w
=
x1
x
=
w
/
2
elif
x0
<
0
and
x1
>
1
:
w
=
1
x
=
0.5
return
x
,
w
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