summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/faceSearch/faceSearch.result.js14
-rw-r--r--megapixels/app/server/api.py14
-rw-r--r--site/assets/css/applets.css3
3 files changed, 26 insertions, 5 deletions
diff --git a/client/faceSearch/faceSearch.result.js b/client/faceSearch/faceSearch.result.js
index 2b223a46..1882def0 100644
--- a/client/faceSearch/faceSearch.result.js
+++ b/client/faceSearch/faceSearch.result.js
@@ -5,10 +5,22 @@ import { courtesyS } from '../util'
import * as actions from './faceSearch.actions'
+const errors = {
+ 'bbox': "Sorry, we couldn't find a face in that image. Please choose an image where the face is large and clear.",
+ 'nomatch': "We didn't find a match.",
+ 'default': "There was an error!",
+}
+
class FaceSearchResult extends Component {
render() {
const { dataset } = this.props.payload
- const { distances, results } = this.props.result
+ const { distances, results, error } = this.props.result
+ if (error) {
+ let errorMessage = errors[error.message] || errors.default
+ return (
+ <div className='result'>{errorMessage}</div>
+ )
+ }
if (!results) {
return (
<div className='result'></div>
diff --git a/megapixels/app/server/api.py b/megapixels/app/server/api.py
index 2f78ecd3..bc60118c 100644
--- a/megapixels/app/server/api.py
+++ b/megapixels/app/server/api.py
@@ -58,6 +58,10 @@ def upload(name):
# get detection as BBox object
bboxes = detector.detect(im_np, largest=True)
+ if not len(bboxes):
+ return jsonify({
+ 'error': 'bbox'
+ })
bbox = bboxes[0]
dim = im_np.shape[:2][::-1]
bbox = bbox.to_dim(dim) # convert back to real dimensions
@@ -73,16 +77,18 @@ def upload(name):
distances, indexes = faiss_dataset.search(query, 10)
if len(indexes) == 0:
- print("weird, no results!")
- return []
+ return jsonify({
+ 'error': 'nomatch'
+ })
# get the results for this single query...
distances = distances[0]
indexes = indexes[0]
if len(indexes) == 0:
- print("no results!")
- return []
+ return jsonify({
+ 'error': 'nomatch'
+ })
lookup = {}
ids = [i+1 for i in indexes]
diff --git a/site/assets/css/applets.css b/site/assets/css/applets.css
index a01703d5..ecba518c 100644
--- a/site/assets/css/applets.css
+++ b/site/assets/css/applets.css
@@ -30,6 +30,9 @@
}
.results > div img {
margin-bottom: 4px;
+ width: 200px;
+ height: 200px;
+ background: rgba(255,255,255,0.05);
}
.results > div:nth-child(3n+1) {
margin-left: 0;