Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3Packages.mtcnn: init at 0.1.1; python3Packages.retinaface: init at 0.0.17; python3Packages.deepface: init at 0.0.92 #347052

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions pkgs/development/python-modules/deepface/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
fire,
flask,
flask-cors,
gdown,
gunicorn,
mtcnn,
numpy,
opencv4,
pandas,
pillow,
pythonOlder,
requests,
retinaface,
setuptools,
tensorflow,
tqdm,
}:

buildPythonPackage rec {
pname = "deepface";
version = "0.0.92";
pyproject = true;

disabled = pythonOlder "3.7";

src = fetchFromGitHub {
owner = "serengil";
repo = "deepface";
rev = "refs/tags/v${version}";
hash = "sha256-Vjm8lfpGyJ7/1CUwIvxXxHqwmv0+iKewYV3vE08gpPQ=";
};

postPatch = ''
# prevent collisions
substituteInPlace setup.py \
--replace-fail "data_files=[(\"\", [\"README.md\", \"requirements.txt\", \"package_info.json\"])]," "" \
--replace-fail "install_requires=requirements," ""

substituteInPlace deepface/detectors/OpenCv.py \
--replace-fail "opencv_home = cv2.__file__" "opencv_home = os.readlink(cv2.__file__)" \
DerDennisOP marked this conversation as resolved.
Show resolved Hide resolved
--replace-fail "folders = opencv_home.split(os.path.sep)[0:-1]" "folders = opencv_home.split(os.path.sep)[0:-4]" \
--replace-fail "return path + \"/data/\"" "return path + \"/share/opencv4/haarcascades/\""
'';

build-system = [ setuptools ];

dependencies = [
fire
flask
flask-cors
gdown
gunicorn
mtcnn
numpy
opencv4
pandas
pillow
requests
retinaface
tensorflow
tqdm
];

# requires internet connection
doCheck = false;

pythonImportsCheck = [ "deepface" ];

meta = {
description = "Lightweight Face Recognition and Facial Attribute Analysis (Age, Gender, Emotion and Race) Library for Python";
homepage = "https://github.com/serengil/deepface";
changelog = "https://github.com/serengil/deepface/releases/tag/v${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ derdennisop ];
};
}
53 changes: 53 additions & 0 deletions pkgs/development/python-modules/mtcnn/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
opencv4,
pytestCheckHook,
pythonOlder,
setuptools,
tensorflow,
}:

buildPythonPackage {
pname = "mtcnn";
version = "0.1.1";
pyproject = true;

disabled = pythonOlder "3.7";

src = fetchFromGitHub {
owner = "ipazc";
repo = "mtcnn";
# No tags / releases; using commit: https://github.com/ipazc/mtcnn/commit/3208d443a8f01d317c65d7c97a03bc0a6143c41d
rev = "3208d443a8f01d317c65d7c97a03bc0a6143c41d";
hash = "sha256-GXUrLJ5XD6V2hT/gjyYSuh/CMMw2xIXKBsYFvQmbLYs=";
};

postPatch = ''
substituteInPlace setup.py \
--replace-fail "setup, setuptools" "setup, find_packages"\
--replace-fail "setuptools.find_packages" "find_packages"\
--replace-fail "opencv-python>=4.1.0" ""\
--replace-fail "keras>=2.0.0" ""\
--replace-fail "tests_require=['nose']," ""
'';

build-system = [ setuptools ];

dependencies = [
opencv4
tensorflow
];

pythonImportsCheck = [ "mtcnn" ];

nativeCheckInputs = [ pytestCheckHook ];

meta = {
description = "MTCNN face detection implementation for TensorFlow, as a PIP package";
SuperSandro2000 marked this conversation as resolved.
Show resolved Hide resolved
homepage = "https://github.com/ipazc/mtcnn";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ derdennisop ];
};
}
64 changes: 64 additions & 0 deletions pkgs/development/python-modules/retinaface/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
gdown,
numpy,
opencv4,
pillow,
pytestCheckHook,
pythonOlder,
setuptools,
tensorflow,
}:

buildPythonPackage rec {
pname = "retinaface";
version = "0.0.17";
pyproject = true;

disabled = pythonOlder "3.7";

src = fetchFromGitHub {
owner = "serengil";
repo = "retinaface";
rev = "refs/tags/v${version}";
hash = "sha256-0s1CSGlK2bF1F2V/IuG2ZqD7CkNfHGvp1M5C3zDnuKs=";
};

postPatch = ''
# prevent collisions
substituteInPlace setup.py \
--replace-fail "data_files=[(\"\", [\"README.md\", \"requirements.txt\", \"package_info.json\"])]," "" \
--replace-fail "install_requires=requirements," ""
'';

# requires internet connection
disabledTestPaths = [
DerDennisOP marked this conversation as resolved.
Show resolved Hide resolved
"tests/test_actions.py"
"tests/test_align_first.py"
"tests/test_expand_face_area.py"
];

build-system = [ setuptools ];

dependencies = [
gdown
numpy
opencv4
pillow
tensorflow
];

nativeCheckInputs = [ pytestCheckHook ];

pythonImportsCheck = [ "retinaface" ];

meta = {
description = "Deep Face Detection Library for Python";
homepage = "https://github.com/serengil/retinaface";
changelog = "https://github.com/serengil/retinaface/releases/tag/v${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ derdennisop ];
};
}
6 changes: 6 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3028,6 +3028,8 @@ self: super: with self; {

deepdish = callPackage ../development/python-modules/deepdish { };

deepface = callPackage ../development/python-modules/deepface { };

deepl = callPackage ../development/python-modules/deepl { };

deepmerge = callPackage ../development/python-modules/deepmerge { };
Expand Down Expand Up @@ -8242,6 +8244,8 @@ self: super: with self; {

msrest = callPackage ../development/python-modules/msrest { };

mtcnn = callPackage ../development/python-modules/mtcnn { };

mt-940 = callPackage ../development/python-modules/mt-940 { };

mullvad-api = callPackage ../development/python-modules/mullvad-api { };
Expand Down Expand Up @@ -13615,6 +13619,8 @@ self: super: with self; {

rethinkdb = callPackage ../development/python-modules/rethinkdb { };

retinaface = callPackage ../development/python-modules/retinaface { };

retry = callPackage ../development/python-modules/retry { };

retry-decorator = callPackage ../development/python-modules/retry-decorator { };
Expand Down