Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
CursedPrograms committed Feb 9, 2024
1 parent 06e5af8 commit bd7172e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
11 changes: 8 additions & 3 deletions scripts/gender_age_predictor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from deepface import DeepFace
from PIL import Image, ImageDraw, ImageFont
import os
import json

def extract_gender_and_age(input_image_path, output_directory):
try:
Expand Down Expand Up @@ -43,9 +44,13 @@ def extract_gender_and_age(input_image_path, output_directory):
# Get the directory of the current script
script_directory = os.path.dirname(os.path.abspath(__file__))

# Specify the paths for input and output images relative to the script's location
input_directory = os.path.join(script_directory, '../input/')
output_directory = os.path.join(script_directory, '../output/')
# Load settings from the JSON file
with open("settings.json", "r") as file:
settings = json.load(file)

# Specify the paths for input and output directories based on the loaded settings
input_directory = os.path.join(script_directory, settings["directories"]["input"])
output_directory = os.path.join(script_directory, settings["directories"]["output"])

# Get a list of all image files in the input directory
image_files = [f for f in os.listdir(input_directory) if os.path.isfile(os.path.join(input_directory, f))]
Expand Down
1 change: 1 addition & 0 deletions scripts/gender_age_predictor_webcam.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cv2
from deepface import DeepFace
import numpy as np
import json

def extract_gender_and_age(frame, face_cascade):
try:
Expand Down
11 changes: 8 additions & 3 deletions scripts/gender_predictor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from deepface import DeepFace
from PIL import Image, ImageDraw, ImageFont
import os
import json

def extract_gender(input_image_path, output_directory):
try:
Expand Down Expand Up @@ -36,9 +37,13 @@ def extract_gender(input_image_path, output_directory):
# Get the directory of the current script
script_directory = os.path.dirname(os.path.abspath(__file__))

# Specify the paths for input and output images relative to the script's location
input_directory = os.path.join(script_directory, '../input/')
output_directory = os.path.join(script_directory, '../output/')
# Load settings from the JSON file
with open("settings.json", "r") as file:
settings = json.load(file)

# Specify the paths for input and output directories based on the loaded settings
input_directory = os.path.join(script_directory, settings["directories"]["input"])
output_directory = os.path.join(script_directory, settings["directories"]["output"])

# Get a list of all image files in the input directory
image_files = [f for f in os.listdir(input_directory) if os.path.isfile(os.path.join(input_directory, f))]
Expand Down
6 changes: 6 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"directories": {
"input": "../input/",
"output": "../output/"
}
}

0 comments on commit bd7172e

Please sign in to comment.