in api/ImageSimilarity/deployment/app.py [0:0]
def FindSimilarImages():
'''
this method will find the closest neighbors for an image provided as a file
'''
if request.method=='POST':
try:
#load image sent in the request
log('Starting FindSimilarImages method')
file = request.files['image'].read()
log('reading file in FindSimilarImages')
#load the # of neighbors to return
neighbors = request.args.get('neighbors')
if neighbors is None:
neighbors = 4 #default
log('using default neighbors: %d' % neighbors)
else:
neighbors = int(neighbors)
print('number of neighbors: %d' % neighbors)
#grab the matches
return generateMatch(img_input = file , k_neighbors = neighbors, input_type = 1)
except Exception as e:
return e