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
2408d4cf
Commit
2408d4cf
authored
4 years ago
by
Herman Andersen Dyrkorn
Browse files
Options
Downloads
Patches
Plain Diff
server working with algorithm
parent
7c544713
No related branches found
No related tags found
1 merge request
!21
Resolve "combine matchsalamander with ai"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
algorithm/train_src/new_straightening.py
+2
-2
2 additions, 2 deletions
algorithm/train_src/new_straightening.py
api/endpoints/findsalamanderinfo.py
+10
-7
10 additions, 7 deletions
api/endpoints/findsalamanderinfo.py
with
12 additions
and
9 deletions
algorithm/train_src/new_straightening.py
+
2
−
2
View file @
2408d4cf
...
...
@@ -9,7 +9,7 @@ from tensorflow.python.keras.layers import Minimum
import
algorithm.train_src.predict_salamander_abdomen
as
psa
from
threading
import
Semaphore
DEEPLABCUT_CONFIG_PATH
=
"
./dlc_model/config.yaml
"
DEEPLABCUT_CONFIG_PATH
=
"
./
algorithm/train_src/
dlc_model/config.yaml
"
########################################
# CONSTANTS
########################################
...
...
@@ -29,7 +29,7 @@ STRAIGTHENED_IMAGE_ASPECT_RATIO = STRAIGTHENED_IMAGE_HEIGHT / STRAIGTHENED_IMAGE
# amount of pixels to add to the width of the shoulder including what the AI estimates:
SHOULDER_ESTIMATION_BUFFER
=
15
# minimum distance between shoulder points in pixels:
MINIMUM_SHOULDER_WIDTH
=
10
0
MINIMUM_SHOULDER_WIDTH
=
5
0
# minimum distance between the points, 2 and 3 in pixels:
MINIMUM_MID_POINT_DISTANCE
=
30
...
...
This diff is collapsed.
Click to expand it.
api/endpoints/findsalamanderinfo.py
+
10
−
7
View file @
2408d4cf
...
...
@@ -2,7 +2,8 @@ from flask import request, jsonify
from
flask_restful
import
Resource
from
flask_jwt_extended
import
get_jwt_identity
,
jwt_required
from
algorithm.train_src.new_straightening
import
straighten
import
cv2
import
os
ALLOWED_EXTENSIONS
=
[
'
jpeg
'
,
'
png
'
,
'
jpg
'
]
...
...
@@ -16,16 +17,18 @@ class FindSalamanderInfo(Resource):
return
jsonify
({
"
message
"
:
"
no file given
"
})
image
=
request
.
files
[
'
image
'
]
user_id
=
get_jwt_identity
()
image
.
filename
=
str
(
user_id
)
+
"
.
"
+
extension
(
image
.
filename
)
image
.
save
(
"
temp_images/
"
+
image
.
filename
)
execution_path
=
os
.
path
.
abspath
(
os
.
getcwd
())
print
(
execution_path
+
"
/temp_images/
"
+
str
(
user_id
)
+
"
.
"
+
extension
(
image
.
filename
))
img
=
cv2
.
imread
(
execution_path
+
"
/temp_images/
"
+
str
(
user_id
)
+
"
.
"
+
extension
(
image
.
filename
),
1
)
if
image
.
filename
!=
''
:
if
image
and
allowed_image
(
image
.
filename
):
# run AI on image
str_image
,
_
,
_
,
_
,
_
=
straighten
(
image
)
if
str_image
:
str_image
.
filename
=
str
(
user_id
)
+
"
_str.png
"
str_image
.
save
(
"
temp_images/
"
+
str_image
.
filename
)
str_image
,
_
,
_
,
_
,
_
=
straighten
(
img
)
if
str_image
is
not
None
:
cv2
.
imwrite
(
"
temp_images/
"
+
str
(
user_id
)
+
"
_str.png
"
,
str_image
)
# store processed and original image
image
.
filename
=
str
(
user_id
)
+
"
.
"
+
extension
(
image
.
filename
)
image
.
save
(
"
temp_images/
"
+
image
.
filename
)
return
jsonify
({
"
sex
"
:
"
AI_sex
"
,
"
species
"
:
"
AI_species
"
})
else
:
return
jsonify
({
"
message
"
:
"
file extension not allowed
"
})
...
...
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