summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--check/app/server/api.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/check/app/server/api.py b/check/app/server/api.py
index 322d899..9643917 100644
--- a/check/app/server/api.py
+++ b/check/app/server/api.py
@@ -30,13 +30,12 @@ def match():
Search by uploading an image
"""
start = time.time()
- logging.debug(start)
file = request.files['q']
fn = file.filename
if fn.endswith('blob'): # FIX PNG IMAGES?
+ logging.debug('received a blob, assuming JPEG')
fn = 'filename.jpg'
- logging.debug(fn)
basename, ext = os.path.splitext(fn)
if ext.lower() not in valid_exts:
@@ -51,7 +50,6 @@ def match():
im = Image.open(file.stream).convert('RGB')
phash = compute_phash_int(im)
- logging.debug(phash)
try:
threshold = int(request.args.get('threshold') or 6)
limit = int(request.args.get('limit') or 1)
@@ -64,6 +62,7 @@ def match():
})
results = search_by_phash(phash=phash, threshold=threshold, limit=limit)
+ logging.debug('query took {0:.2g} s.'.format(time.time() - start))
if len(results) == 0:
if add:
@@ -73,12 +72,14 @@ def match():
return jsonify({
'success': True,
'match': False,
+ 'timing': time.time() - start,
})
else:
return jsonify({
'success': True,
'match': False,
'results': [],
+ 'timing': time.time() - start,
})
if limit > 1:
@@ -86,10 +87,12 @@ def match():
'success': True,
'match': True,
'results': results,
+ 'timing': time.time() - start,
})
return jsonify({
'success': True,
'match': True,
'closest_match': results[0],
+ 'timing': time.time() - start,
})