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
Merge requests
!3
Resolve "findSalamanderInfo endpoint"
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Resolve "findSalamanderInfo endpoint"
2-findsalamanderinfo-endpoint
into
master
Overview
0
Commits
4
Pipelines
0
Changes
2
Merged
Resolve "findSalamanderInfo endpoint"
Herman Andersen Dyrkorn
requested to merge
2-findsalamanderinfo-endpoint
into
master
Feb 4, 2021
Overview
0
Commits
4
Pipelines
0
Changes
2
Closes
#2 (closed)
Edited
Feb 4, 2021
by
Herman Andersen Dyrkorn
0
0
Merge request reports
Compare
master
version 3
8cc99488
Feb 4, 2021
version 2
a6f32306
Feb 4, 2021
version 1
ccfd76f7
Feb 4, 2021
master (base)
and
latest version
latest version
02907428
4 commits,
Feb 4, 2021
version 3
8cc99488
3 commits,
Feb 4, 2021
version 2
a6f32306
2 commits,
Feb 4, 2021
version 1
ccfd76f7
1 commit,
Feb 4, 2021
2 files
+
42
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
src/main.py
+
25
−
2
View file @ 02907428
Edit in single-file editor
Open in Web IDE
Show full file
@@ -15,14 +15,23 @@ class MatchSalamander(Resource):
original_image_path
=
get_path
(
data
,
"
original/
"
)
processed_image_path
=
get_path
(
data
,
"
processed/
"
)
if
directory_not_empty
(
original_image_path
):
image
.
save
(
original_image_path
+
image
.
filename
)
# start processing with AI
# load preprocessed salamanders from processed_image_path
output
=
{
"
message
"
:
"
match or miss
"
}
# brute force matching
# if match:
image
.
save
(
original_image_path
+
image
.
filename
)
output
=
{
"
message
"
:
"
match with id something
"
}
# if miss:
# create new salamander in DB
# save original image
# save processed image
# output = new salamander with ID something, no match
else
:
os
.
makedirs
(
original_image_path
)
os
.
makedirs
(
processed_image_path
)
# start processing with AI
# create a new salamander in DB
image
.
save
(
original_image_path
+
image
.
filename
)
output
=
{
"
message
"
:
"
no salamanders to match against
"
}
else
:
@@ -31,7 +40,21 @@ class MatchSalamander(Resource):
return
output
class
FindSalamanderInfo
(
Resource
):
@staticmethod
def
post
():
image
=
request
.
files
[
'
image
'
]
if
image
.
filename
!=
''
:
# run AI on image
output
=
{
"
sex
"
:
"
AI_sex
"
,
"
species
"
:
"
AI_species
"
}
else
:
output
=
{
"
message
"
:
"
something wrong with image
"
}
return
output
api
.
add_resource
(
MatchSalamander
,
"
/matchSalamander
"
)
api
.
add_resource
(
FindSalamanderInfo
,
"
/findSalamanderInfo
"
)
def
get_path
(
data
,
end_directory
):
Loading