Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.face
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
bob
bob.bio.face
Commits
5a260a1e
Commit
5a260a1e
authored
4 years ago
by
Laurent COLBOIS
Browse files
Options
Downloads
Patches
Plain Diff
Formatting
parent
bb5b1b70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!92
MultiFaceCrop
Pipeline
#46758
passed
4 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/bio/face/config/baseline/helpers.py
+60
-63
60 additions, 63 deletions
bob/bio/face/config/baseline/helpers.py
with
60 additions
and
63 deletions
bob/bio/face/config/baseline/helpers.py
+
60
−
63
View file @
5a260a1e
...
...
@@ -30,58 +30,56 @@ def embedding_transformer_default_cropping(cropped_image_size, annotation_type):
"""
if
isinstance
(
annotation_type
,
list
):
return
[
embedding_transformer_default_cropping
(
cropped_image_size
,
item
)
for
item
in
annotation_type
]
else
:
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
=
cropped_image_size
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
=
cropped_image_size
if
annotation_type
==
"
bounding-box
"
:
if
annotation_type
==
"
bounding-box
"
:
TOP_LEFT_POS
=
(
0
,
0
)
BOTTOM_RIGHT_POS
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
)
cropped_positions
=
{
"
topleft
"
:
TOP_LEFT_POS
,
"
bottomright
"
:
BOTTOM_RIGHT_POS
}
TOP_LEFT_POS
=
(
0
,
0
)
BOTTOM_RIGHT_POS
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
)
cropped_positions
=
{
"
topleft
"
:
TOP_LEFT_POS
,
"
bottomright
"
:
BOTTOM_RIGHT_POS
}
elif
annotation_type
==
"
eyes-center
"
:
elif
annotation_type
==
"
eyes-center
"
:
RIGHT_EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
1
/
3
*
CROPPED_IMAGE_WIDTH
),
)
LEFT_EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
2
/
3
*
CROPPED_IMAGE_WIDTH
),
)
cropped_positions
=
{
"
leye
"
:
LEFT_EYE_POS
,
"
reye
"
:
RIGHT_EYE_POS
}
RIGHT_EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
1
/
3
*
CROPPED_IMAGE_WIDTH
),
)
LEFT_EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
2
/
3
*
CROPPED_IMAGE_WIDTH
),
)
cropped_positions
=
{
"
leye
"
:
LEFT_EYE_POS
,
"
reye
"
:
RIGHT_EYE_POS
}
elif
annotation_type
==
"
left-profile
"
:
elif
annotation_type
==
"
left-profile
"
:
EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
3
/
8
*
CROPPED_IMAGE_WIDTH
),
)
MOUTH_POS
=
(
round
(
5
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
3
/
8
*
CROPPED_IMAGE_WIDTH
),
)
cropped_positions
=
{
"
leye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
3
/
8
*
CROPPED_IMAGE_WIDTH
),
)
MOUTH_POS
=
(
round
(
5
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
3
/
8
*
CROPPED_IMAGE_WIDTH
),
)
cropped_positions
=
{
"
leye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
elif
annotation_type
==
"
right-profile
"
:
elif
annotation_type
==
"
right-profile
"
:
EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
5
/
8
*
CROPPED_IMAGE_WIDTH
),
)
MOUTH_POS
=
(
round
(
5
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
5
/
8
*
CROPPED_IMAGE_WIDTH
),
)
cropped_positions
=
{
"
reye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
5
/
8
*
CROPPED_IMAGE_WIDTH
),
)
MOUTH_POS
=
(
round
(
5
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
5
/
8
*
CROPPED_IMAGE_WIDTH
),
)
cropped_positions
=
{
"
reye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
else
:
else
:
cropped_positions
=
None
cropped_positions
=
None
return
cropped_positions
return
cropped_positions
def
legacy_default_cropping
(
cropped_image_size
,
annotation_type
):
...
...
@@ -108,39 +106,38 @@ def legacy_default_cropping(cropped_image_size, annotation_type):
"""
if
isinstance
(
annotation_type
,
list
):
return
[
legacy_default_cropping
(
cropped_image_size
,
item
)
for
item
in
annotation_type
]
else
:
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
=
cropped_image_size
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
=
cropped_image_size
if
annotation_type
==
"
bounding-box
"
:
if
annotation_type
==
"
bounding-box
"
:
TOP_LEFT_POS
=
(
0
,
0
)
BOTTOM_RIGHT_POS
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
)
cropped_positions
=
{
"
topleft
"
:
TOP_LEFT_POS
,
"
bottomright
"
:
BOTTOM_RIGHT_POS
}
TOP_LEFT_POS
=
(
0
,
0
)
BOTTOM_RIGHT_POS
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
)
cropped_positions
=
{
"
topleft
"
:
TOP_LEFT_POS
,
"
bottomright
"
:
BOTTOM_RIGHT_POS
}
elif
annotation_type
==
"
eyes-center
"
:
elif
annotation_type
==
"
eyes-center
"
:
RIGHT_EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
4
-
1
)
LEFT_EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
4
*
3
)
cropped_positions
=
{
"
leye
"
:
LEFT_EYE_POS
,
"
reye
"
:
RIGHT_EYE_POS
}
RIGHT_EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
4
-
1
)
LEFT_EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
4
*
3
)
cropped_positions
=
{
"
leye
"
:
LEFT_EYE_POS
,
"
reye
"
:
RIGHT_EYE_POS
}
elif
annotation_type
==
"
left-profile
"
:
# Main reference https://gitlab.idiap.ch/bob/bob.chapter.FRICE/-/blob/master/bob/chapter/FRICE/script/pose.py
EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
7
*
3
-
2
)
MOUTH_POS
=
(
CROPPED_IMAGE_HEIGHT
//
3
*
2
,
CROPPED_IMAGE_WIDTH
//
7
*
3
-
2
)
cropped_positions
=
{
"
leye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
elif
annotation_type
==
"
left-profile
"
:
# Main reference https://gitlab.idiap.ch/bob/bob.chapter.FRICE/-/blob/master/bob/chapter/FRICE/script/pose.py
EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
7
*
3
-
2
)
MOUTH_POS
=
(
CROPPED_IMAGE_HEIGHT
//
3
*
2
,
CROPPED_IMAGE_WIDTH
//
7
*
3
-
2
)
cropped_positions
=
{
"
leye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
elif
annotation_type
==
"
right-profile
"
:
# Main reference https://gitlab.idiap.ch/bob/bob.chapter.FRICE/-/blob/master/bob/chapter/FRICE/script/pose.py
EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
7
*
4
+
2
)
MOUTH_POS
=
(
CROPPED_IMAGE_HEIGHT
//
3
*
2
,
CROPPED_IMAGE_WIDTH
//
7
*
4
+
2
)
cropped_positions
=
{
"
reye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
elif
annotation_type
==
"
right-profile
"
:
# Main reference https://gitlab.idiap.ch/bob/bob.chapter.FRICE/-/blob/master/bob/chapter/FRICE/script/pose.py
EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
7
*
4
+
2
)
MOUTH_POS
=
(
CROPPED_IMAGE_HEIGHT
//
3
*
2
,
CROPPED_IMAGE_WIDTH
//
7
*
4
+
2
)
cropped_positions
=
{
"
reye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
else
:
else
:
cropped_positions
=
None
cropped_positions
=
None
return
cropped_positions
return
cropped_positions
def
embedding_transformer
(
...
...
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