Skip to content

Commit

Permalink
python3Packages.mtcnn: init at 0.1.1; python3Packages.retinaface: ini…
Browse files Browse the repository at this point in the history
…t at 0.0.17; python3Packages.deepface: init at 0.0.92 (#347052)
  • Loading branch information
SuperSandro2000 authored Oct 9, 2024
2 parents de4883c + ac76792 commit 8ff900b
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 0 deletions.
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__)" \
--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";
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 = [
"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 @@ -3034,6 +3034,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 @@ -8248,6 +8250,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 @@ -13627,6 +13631,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

0 comments on commit 8ff900b

Please sign in to comment.