From a4479ceb14c24dc694f46e1270809da1de39c969 Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Sun, 10 Nov 2024 18:40:38 +0000 Subject: [PATCH] unit tests --- .github/workflows/tests.yml | 2 + .../deepface-api.postman_collection.json | 150 ++++++++++++++++-- requirements_local | 2 +- 3 files changed, 142 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c0550349b..92b03bcc2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,6 +37,8 @@ jobs: run: | python -m pip install --upgrade pip pip install pytest + pip install Werkzeug==2.0.2 + pip install flask==2.0.2 pip install . - name: Test with pytest diff --git a/deepface/api/postman/deepface-api.postman_collection.json b/deepface/api/postman/deepface-api.postman_collection.json index 9ab8b2dec..539993d81 100644 --- a/deepface/api/postman/deepface-api.postman_collection.json +++ b/deepface/api/postman/deepface-api.postman_collection.json @@ -1,12 +1,54 @@ { "info": { - "_postman_id": "4c0b144e-4294-4bdd-8072-bcb326b1fed2", + "_postman_id": "26c5ee53-1f4b-41db-9342-3617c90059d3", "name": "deepface-api", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { - "name": "Represent", + "name": "Represent - form data", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "img", + "type": "file", + "src": "/Users/sefik/Desktop/deepface/tests/dataset/img1.jpg" + }, + { + "key": "model_name", + "value": "Facenet", + "type": "text" + } + ], + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://127.0.0.1:5005/represent", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "5005", + "path": [ + "represent" + ] + } + }, + "response": [] + }, + { + "name": "Represent - default", "request": { "method": "POST", "header": [], @@ -20,7 +62,7 @@ } }, "url": { - "raw": "http://127.0.0.1:5000/represent", + "raw": "http://127.0.0.1:5005/represent", "protocol": "http", "host": [ "127", @@ -28,7 +70,7 @@ "0", "1" ], - "port": "5000", + "port": "5005", "path": [ "represent" ] @@ -37,7 +79,7 @@ "response": [] }, { - "name": "Face verification", + "name": "Face verification - default", "request": { "method": "POST", "header": [], @@ -51,7 +93,54 @@ } }, "url": { - "raw": "http://127.0.0.1:5000/verify", + "raw": "http://127.0.0.1:5005/verify", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "5005", + "path": [ + "verify" + ] + } + }, + "response": [] + }, + { + "name": "Face verification - form data", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "img1", + "type": "file", + "src": "/Users/sefik/Desktop/deepface/tests/dataset/img1.jpg" + }, + { + "key": "img2", + "type": "file", + "src": "/Users/sefik/Desktop/deepface/tests/dataset/img2.jpg" + }, + { + "key": "model_name", + "value": "Facenet", + "type": "text" + } + ], + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://127.0.0.1:5005/verify", "protocol": "http", "host": [ "127", @@ -59,7 +148,7 @@ "0", "1" ], - "port": "5000", + "port": "5005", "path": [ "verify" ] @@ -68,13 +157,13 @@ "response": [] }, { - "name": "Face analysis", + "name": "Face analysis - default", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"img\": \"/Users/sefik/Desktop/deepface/tests/dataset/couple.jpg\",\n \"actions\": [\"age\", \"gender\", \"emotion\", \"race\"]\n}", + "raw": "{\n \"img\": \"/Users/sefik/Desktop/deepface/tests/dataset/img1.jpg\",\n \"actions\": [\"age\", \"gender\", \"emotion\", \"race\"]\n}", "options": { "raw": { "language": "json" @@ -82,7 +171,7 @@ } }, "url": { - "raw": "http://127.0.0.1:5000/analyze", + "raw": "http://127.0.0.1:5005/analyze", "protocol": "http", "host": [ "127", @@ -90,7 +179,46 @@ "0", "1" ], - "port": "5000", + "port": "5005", + "path": [ + "analyze" + ] + } + }, + "response": [] + }, + { + "name": "Face analysis - form data", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "img", + "type": "file", + "src": "/Users/sefik/Desktop/deepface/tests/dataset/img1.jpg" + }, + { + "key": "actions", + "value": "\"[age, gender]\"", + "type": "text" + } + ], + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://localhost:5005/analyze", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "5005", "path": [ "analyze" ] diff --git a/requirements_local b/requirements_local index 22bbe11d1..1705b13a2 100644 --- a/requirements_local +++ b/requirements_local @@ -3,4 +3,4 @@ pandas==2.0.3 Pillow==9.0.0 opencv-python==4.9.0.80 tensorflow==2.13.1 -keras==2.13.1 +keras==2.13.1 \ No newline at end of file