Skip to content

Commit

Permalink
working version!
Browse files Browse the repository at this point in the history
  • Loading branch information
ak8000 committed May 1, 2024
1 parent fee0862 commit 5c60650
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion machine-learning-client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
13 changes: 6 additions & 7 deletions machine-learning-client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions machine-learning-client/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5c60650

Please sign in to comment.