diff --git a/docs/app.js b/docs/app.js index 6f3fc44..26dbf63 100644 --- a/docs/app.js +++ b/docs/app.js @@ -20,7 +20,9 @@ function init() { // var url = "http://127.0.0.1:5000/classify_image"; // var url = "/classify_image"; - var url = "/api/classify_image"; // This should match your proxy configuration + // var url = "/api/classify_image"; // This should match your proxy configuration + var url = "/api/classify_image"; // This points to your backend on Vercel. + $.post( diff --git a/server/artifacts/class_dictionary.json b/server/api/artifacts/class_dictionary.json similarity index 100% rename from server/artifacts/class_dictionary.json rename to server/api/artifacts/class_dictionary.json diff --git a/server/artifacts/saved_model.pkl b/server/api/artifacts/saved_model.pkl similarity index 100% rename from server/artifacts/saved_model.pkl rename to server/api/artifacts/saved_model.pkl diff --git a/server/b64.txt b/server/api/b64.txt similarity index 100% rename from server/b64.txt rename to server/api/b64.txt diff --git a/server/api/classify_image.py b/server/api/classify_image.py new file mode 100644 index 0000000..3e9ae39 --- /dev/null +++ b/server/api/classify_image.py @@ -0,0 +1,15 @@ +from server import util +from flask import Flask, request, jsonify + +app = Flask(__name__) + +@app.route('/api/classify_image', methods=['POST']) +def classify_image(): + image_data = request.form['image_data'] + response = jsonify(util.classify_image(image_data)) + response.headers.add('Access-Control-Allow-Origin', '*') + return response + +if __name__ == "__main__": + util.load_saved_artifacts() + app.run() diff --git a/server/opencv/haarcascades/haarcascade_eye.xml b/server/api/haarcascades/haarcascade_eye.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_eye.xml rename to server/api/haarcascades/haarcascade_eye.xml diff --git a/server/opencv/haarcascades/haarcascade_eye_tree_eyeglasses.xml b/server/api/haarcascades/haarcascade_eye_tree_eyeglasses.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_eye_tree_eyeglasses.xml rename to server/api/haarcascades/haarcascade_eye_tree_eyeglasses.xml diff --git a/server/opencv/haarcascades/haarcascade_frontalcatface.xml b/server/api/haarcascades/haarcascade_frontalcatface.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_frontalcatface.xml rename to server/api/haarcascades/haarcascade_frontalcatface.xml diff --git a/server/opencv/haarcascades/haarcascade_frontalcatface_extended.xml b/server/api/haarcascades/haarcascade_frontalcatface_extended.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_frontalcatface_extended.xml rename to server/api/haarcascades/haarcascade_frontalcatface_extended.xml diff --git a/server/opencv/haarcascades/haarcascade_frontalface_alt.xml b/server/api/haarcascades/haarcascade_frontalface_alt.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_frontalface_alt.xml rename to server/api/haarcascades/haarcascade_frontalface_alt.xml diff --git a/server/opencv/haarcascades/haarcascade_frontalface_alt2.xml b/server/api/haarcascades/haarcascade_frontalface_alt2.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_frontalface_alt2.xml rename to server/api/haarcascades/haarcascade_frontalface_alt2.xml diff --git a/server/opencv/haarcascades/haarcascade_frontalface_alt_tree.xml b/server/api/haarcascades/haarcascade_frontalface_alt_tree.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_frontalface_alt_tree.xml rename to server/api/haarcascades/haarcascade_frontalface_alt_tree.xml diff --git a/server/opencv/haarcascades/haarcascade_frontalface_default.xml b/server/api/haarcascades/haarcascade_frontalface_default.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_frontalface_default.xml rename to server/api/haarcascades/haarcascade_frontalface_default.xml diff --git a/server/opencv/haarcascades/haarcascade_fullbody.xml b/server/api/haarcascades/haarcascade_fullbody.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_fullbody.xml rename to server/api/haarcascades/haarcascade_fullbody.xml diff --git a/server/opencv/haarcascades/haarcascade_lefteye_2splits.xml b/server/api/haarcascades/haarcascade_lefteye_2splits.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_lefteye_2splits.xml rename to server/api/haarcascades/haarcascade_lefteye_2splits.xml diff --git a/server/opencv/haarcascades/haarcascade_licence_plate_rus_16stages.xml b/server/api/haarcascades/haarcascade_licence_plate_rus_16stages.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_licence_plate_rus_16stages.xml rename to server/api/haarcascades/haarcascade_licence_plate_rus_16stages.xml diff --git a/server/opencv/haarcascades/haarcascade_lowerbody.xml b/server/api/haarcascades/haarcascade_lowerbody.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_lowerbody.xml rename to server/api/haarcascades/haarcascade_lowerbody.xml diff --git a/server/opencv/haarcascades/haarcascade_profileface.xml b/server/api/haarcascades/haarcascade_profileface.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_profileface.xml rename to server/api/haarcascades/haarcascade_profileface.xml diff --git a/server/opencv/haarcascades/haarcascade_righteye_2splits.xml b/server/api/haarcascades/haarcascade_righteye_2splits.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_righteye_2splits.xml rename to server/api/haarcascades/haarcascade_righteye_2splits.xml diff --git a/server/opencv/haarcascades/haarcascade_russian_plate_number.xml b/server/api/haarcascades/haarcascade_russian_plate_number.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_russian_plate_number.xml rename to server/api/haarcascades/haarcascade_russian_plate_number.xml diff --git a/server/opencv/haarcascades/haarcascade_smile.xml b/server/api/haarcascades/haarcascade_smile.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_smile.xml rename to server/api/haarcascades/haarcascade_smile.xml diff --git a/server/opencv/haarcascades/haarcascade_upperbody.xml b/server/api/haarcascades/haarcascade_upperbody.xml similarity index 100% rename from server/opencv/haarcascades/haarcascade_upperbody.xml rename to server/api/haarcascades/haarcascade_upperbody.xml diff --git a/server/server.py b/server/api/server.py similarity index 100% rename from server/server.py rename to server/api/server.py diff --git a/server/util.py b/server/api/util.py similarity index 100% rename from server/util.py rename to server/api/util.py diff --git a/server/wavelet.py b/server/api/wavelet.py similarity index 100% rename from server/wavelet.py rename to server/api/wavelet.py diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..9dad9f9 --- /dev/null +++ b/vercel.json @@ -0,0 +1,8 @@ +{ + "routes": [ + { + "src": "/api/classify_image", + "dest": "/server/api/classify_image.py" + } + ] +}