From 9f49868c66f9ba54d8284341ad59cbbde77ccdf9 Mon Sep 17 00:00:00 2001 From: Aric Lasry Date: Tue, 21 Dec 2021 11:24:06 +0100 Subject: [PATCH 1/6] Add /recent_images API endpoint --- backend/app.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/backend/app.py b/backend/app.py index a8893a5..67135d3 100644 --- a/backend/app.py +++ b/backend/app.py @@ -12,6 +12,8 @@ from flask_cors import CORS import uuid from flask import send_from_directory +import time +import os model = keras.models.load_model('multi-keras.h5') @@ -58,6 +60,18 @@ def send_js(path): return send_from_directory('images', path) +@app.route('/healthcheck') +def view_healthcheck(): + + return jsonify({'status': 'ok photoroom x aricc', "time": time.time()* 1000}) + +@app.route('/recent_images') +def view_recent_images(): + paths = get_most_recent_photos() + + return jsonify({'paths': paths}), 200 + + def readb64(encoded_data): nparr = np.fromstring(base64.b64decode(encoded_data), np.uint8) img = cv2.imdecode(nparr, cv2.IMREAD_COLOR) @@ -78,11 +92,19 @@ def process_upload(data): combined, _ = add_pink_hair(img) combined = (combined * 255.0).astype(np.uint8) - path = 'images/{}.jpg'.format(uuid.uuid4()) + # We are using the timestamp ms as a sorting key to show the post recent + # pictures taken to our frontend, and we use a uuid4 as a unique identifier + path = 'images/{}{}.jpg'.format(time.time(), uuid.uuid4()) cv2.imwrite(path, combined) return jsonify({'path': '/' + path}) + +def get_most_recent_photos(directory='images'): + files = [os.path.join(directory, f) for f in os.listdir('images') if os.path.isfile(os.path.join('images', f))] + files.sort(reverse=True) + return files + graph = None graph = tf.get_default_graph() From 752e11fd83dc68dad1ff69ccd7a8d91b8cb2f5f1 Mon Sep 17 00:00:00 2001 From: Aric Lasry Date: Tue, 21 Dec 2021 11:53:39 +0100 Subject: [PATCH 2/6] Add material UI --- package.json | 5 + public/index.html | 8 + yarn.lock | 1564 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 1551 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index b12112a..216f8af 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,9 @@ "version": "0.1.0", "private": true, "dependencies": { + "@emotion/react": "^11.7.1", + "@emotion/styled": "^11.6.0", + "@mui/material": "^5.2.5", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", @@ -11,6 +14,8 @@ "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "blueimp-load-image": "^5.16.0", + "install": "^0.13.0", + "npm": "^8.3.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", diff --git a/public/index.html b/public/index.html index 52cccdd..00ec45d 100644 --- a/public/index.html +++ b/public/index.html @@ -13,6 +13,14 @@ manifest.json provides metadata used when your web app is installed on a user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ --> + +