Skip to content
Snippets Groups Projects

Resolve "findSalamanderInfo endpoint"

Files

+ 25
2
@@ -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