Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
automated_image_processing
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
Releases
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hyunseok_Sang
automated_image_processing
Commits
6f284be5
Commit
6f284be5
authored
2 years ago
by
Hyunseok_Sang
Browse files
Options
Downloads
Patches
Plain Diff
안면 인식 Service 클래스 추가
parent
c5445fad
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
back-end2/src/services/face_detection_service.py
+29
-0
29 additions, 0 deletions
back-end2/src/services/face_detection_service.py
with
29 additions
and
0 deletions
back-end2/src/services/face_detection_service.py
0 → 100644
+
29
−
0
View file @
6f284be5
from
retinaface
import
RetinaFace
from
utils.image.image_converter
import
ImageConverter
class
FaceDetectionService
:
# https://github.com/serengil/retinaface
def
detect_faces
(
self
,
image_bytes
,
normalized
=
True
):
image
=
ImageConverter
().
convert_to_np_image
(
image_bytes
)
data
=
RetinaFace
.
detect_faces
(
image
)
if
normalized
is
False
:
# [left, top, right, bottom]
faceDataList
=
{
face
:
{
'
facial_area
'
:
{
"
left
"
:
int
(
info
[
'
facial_area
'
][
0
]),
"
top
"
:
int
(
info
[
'
facial_area
'
][
1
]),
"
right
"
:
int
(
info
[
'
facial_area
'
][
2
]),
"
bottom
"
:
int
(
info
[
'
facial_area
'
][
3
])}}
for
face
,
info
in
data
.
items
()}
else
:
img_width
=
image
.
shape
[
1
]
img_height
=
image
.
shape
[
0
]
faceDataList
=
{
face
:
{
'
facial_area
'
:
{
"
left
"
:
int
(
info
[
'
facial_area
'
][
0
])
/
img_width
,
"
top
"
:
int
(
info
[
'
facial_area
'
][
1
])
/
img_height
,
"
right
"
:
int
(
info
[
'
facial_area
'
][
2
])
/
img_width
,
"
bottom
"
:
int
(
info
[
'
facial_area
'
][
3
])
/
img_height
}}
for
face
,
info
in
data
.
items
()}
return
faceDataList
\ 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