Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Salamander - API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Herman Andersen Dyrkorn
Salamander - API
Commits
83800a74
Commit
83800a74
authored
Mar 16, 2021
by
Eirik Martin Danielsen
Browse files
Options
Downloads
Patches
Plain Diff
estimage code
parent
c208bc1d
No related branches found
No related tags found
1 merge request
!37
Resolve "rematch function and endpoint"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+3
-1
3 additions, 1 deletion
.gitignore
algorithm/train_src/estimate_gender.py
+17
-13
17 additions, 13 deletions
algorithm/train_src/estimate_gender.py
api/endpoints/findsalamanderinfo.py
+3
-2
3 additions, 2 deletions
api/endpoints/findsalamanderinfo.py
with
23 additions
and
16 deletions
.gitignore
+
3
−
1
View file @
83800a74
...
...
@@ -3,6 +3,8 @@ venv
images
__pycache__
algorithm/train_src/dlc_model
algorithm/train_src/imageai_model
img_analyze/*.png
env
temp_images
*.db
\ No newline at end of file
This diff is collapsed.
Click to expand it.
algorithm/train_src/estimate_gender.py
+
17
−
13
View file @
83800a74
...
...
@@ -166,6 +166,8 @@ def estimate_image(detection_model_path: str = abs_path_imageai_model,
:return detected_objects_image_array:
"""
with
_ACCESS_TF_AND_GPU_SEMA
:
gender
=
"
AI_sex
"
if
os
.
path
.
isfile
(
detection_model_path
)
and
os
.
path
.
isfile
(
configuration_json
):
manager
=
Manager
()
return_dict
=
manager
.
list
()
# return_dict = multiprocessing.Value("d", [], lock=False)
...
...
@@ -177,8 +179,10 @@ def estimate_image(detection_model_path: str = abs_path_imageai_model,
p
=
Process
(
target
=
run_estimation
,
args
=
args
)
p
.
start
()
p
.
join
()
return
return_dict
[
0
],
return_dict
[
1
],
return_dict
[
2
],
return_dict
[
3
]
if
return_dict
[
0
][
'
name
'
]:
gender
=
return_dict
[
0
][
'
name
'
]
return
gender
,
return_dict
[
1
],
return_dict
[
2
],
return_dict
[
3
]
return
gender
,
None
,
None
,
None
class
BoundBox
:
def
__init__
(
self
,
xmin
,
ymin
,
xmax
,
ymax
,
objness
=
None
,
classes
=
None
):
...
...
This diff is collapsed.
Click to expand it.
api/endpoints/findsalamanderinfo.py
+
3
−
2
View file @
83800a74
...
...
@@ -7,7 +7,7 @@ import cv2
import
os
from
api
import
limiter
from
image_encoder.image_encoder
import
*
from
path_constants
import
image_type
from
path_constants
import
image_type
,
abs_path_imageai_model
,
abs_path_imageai_config
ALLOWED_EXTENSIONS
=
[
'
jpg
'
,
'
png
'
,
'
jpeg
'
]
...
...
@@ -38,7 +38,8 @@ class FindSalamanderInfo(Resource):
str_image
=
cv2
.
cvtColor
(
str_image
,
cv2
.
COLOR_BGR2RGB
)
cv2
.
imwrite
(
os
.
path
.
join
(
temp_img_path
,
str
(
user_id
)
+
"
_str.
"
+
image_type
),
str_image
)
encoded
=
encode
(
os
.
path
.
join
(
temp_img_path
,
str
(
user_id
)
+
"
_str.
"
+
image_type
))[
2
:
-
1
]
return
jsonify
({
"
sex
"
:
"
AI_sex
"
,
"
species
"
:
"
AI_species
"
,
"
status
"
:
200
,
"
image
"
:
encoded
})
gender
,
_
,
_
,
_
=
estimate_image
(
abs_path_imageai_model
,
abs_path_imageai_config
)
return
jsonify
({
"
sex
"
:
gender
,
"
species
"
:
"
AI_species
"
,
"
status
"
:
200
,
"
image
"
:
encoded
})
else
:
return
jsonify
({
"
message
"
:
"
image could not be processed
"
,
"
status
"
:
400
})
...
...
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