Skip to content
Snippets Groups Projects
Commit b0b8d6c0 authored by Herman Andersen Dyrkorn's avatar Herman Andersen Dyrkorn
Browse files

processing juvenile salamanders

parent 96ca710b
No related branches found
No related tags found
1 merge request!18Resolve "refactoring matchsalamander and register location endpoint"
......@@ -6,6 +6,8 @@ import shutil
from api import db
from api.models.dbmodels import Location
from api.models.dbmodels import Salamander, SalamanderGrowth
from algorithm.train_src.new_straightening import straighten
from algorithm.main_src.new_matching import match_file_strcture
APPROVED_SEX = ["male", "female", "juvenile"]
APPROVED_SPECIES = ["smooth_newt", "northern_crested_newt"]
......@@ -28,7 +30,7 @@ class MatchSalamander(Resource):
if data['confirmed']:
path_to_image_for_match = "./temp_images/" + str(user_id) + "_str.jpeg"
path_to_original_image = "./temp_images/" + str(user_id) + ".jpeg"
path_to_images = "images/" + data['location'].lower() + "/" + data['species'] + "/" + data['sex'] + "/"
path_to_images = "./images/" + data['location'].lower() + "/" + data['species'] + "/" + data['sex'] + "/"
if data['sex'] != "juvenile":
hi = "g"
# start processing with AI
......@@ -45,16 +47,11 @@ class MatchSalamander(Resource):
os.makedirs(path_for_new_salamander)
move_and_rename_original(path_for_new_salamander, path_to_original_image)
return jsonify({"message": "new juvenile in database", "id": salamander_id[0]})
# if miss:
# create new salamander in DB
# save original image
# save processed image
# output = new salamander with ID something, no match
else:
return jsonify({"message": "invalid sex or location"})
return jsonify({"message": "image was not accepted by user"})
else:
return jsonify({"message": "invalid sex or location"})
return jsonify({"message": "invalid sex, species or location"})
else:
return jsonify({"message": "errors in form data"})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment