From 5c60650f370aaa68269a1132bbb71485930dfc39 Mon Sep 17 00:00:00 2001 From: ak8000 Date: Tue, 30 Apr 2024 20:52:52 -0400 Subject: [PATCH] working version! --- machine-learning-client/Dockerfile | 1 - machine-learning-client/api.py | 13 ++++++------- machine-learning-client/api_server.py | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/machine-learning-client/Dockerfile b/machine-learning-client/Dockerfile index 215f0d0..6c04de8 100644 --- a/machine-learning-client/Dockerfile +++ b/machine-learning-client/Dockerfile @@ -11,7 +11,6 @@ WORKDIR /usr/src/app COPY . /usr/src/app -RUN pip install --retries=5 --default-timeout=300 opencv-python RUN pip install --retries=3 --default-timeout=150 -r requirements.txt diff --git a/machine-learning-client/api.py b/machine-learning-client/api.py index 76ab5c1..b715ab6 100644 --- a/machine-learning-client/api.py +++ b/machine-learning-client/api.py @@ -12,19 +12,18 @@ def analyze_image(img_path): """ Analyze an image for age and gender using DeepFace. - Parameters: img_path (str): Path to the image file - Returns: list: Analysis results including age """ try: - logging.info("Analyzing the image at path: %s", img_path) - result = DeepFace.analyze(img_path=img_path, actions=["age", "gender", "emotion", "race"]) - logging.info("Analysis result: %s", result) - # Updated to access dictionary values directly - return [result[0]["age"], result[0]["dominant_gender"], result[0]["dominant_emotion"], result[0]["dominant_race"]] + logging.info("Analyzing the image at path: %s", img_path) + result = DeepFace.analyze(img_path=img_path, actions=["age", "gender", "emotion", "race"]) + logging.info("Analysis result: %s", result) + + return [result[0]["age"], result[0]["dominant_gender"], result[0]["dominant_emotion"], result[0]["dominant_race"]] + except Exception as e: logging.error("An error occurred during image analysis: %s", e) raise \ No newline at end of file diff --git a/machine-learning-client/api_server.py b/machine-learning-client/api_server.py index dc2131b..a365487 100644 --- a/machine-learning-client/api_server.py +++ b/machine-learning-client/api_server.py @@ -12,9 +12,9 @@ app = Flask(__name__) serverOptions = { - "socketTimeoutMS": 6000000, # 10 minutes - "connectTimeoutMS": 3000000, # 30 seconds - "serverSelectionTimeoutMS": 3000000, # 30 seconds + "socketTimeoutMS": 600000, # 10 minutes + "connectTimeoutMS": 300000, # 30 seconds + "serverSelectionTimeoutMS": 300000, # 30 seconds } client = MongoClient("mongodb://mongodb:27017/", **serverOptions)