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

pythonPackages.face_recognition: init at 1.2.1 #37566

Merged
merged 1 commit into from Mar 23, 2018

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Mar 21, 2018

Motivation for this change

Adds the python package face_recognition and its dependency
face_recognition_models.

This package is a wrapper for dlib which is able to detect faces in a
given image. I checked the package with the following expression:

with import ./. { };

stdenv.mkDerivation {
  name = "facetest";
  src = null;
  buildInputs = with pythonPackages; [ face_recognition ];
}

The package works perfectly fine in a nix-shell:

$ nix-shell
[nix-shell:~]$ python
Python 2.7.14 (default, Sep 16 2017, 17:49:51)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import face_recognition
>>> img = face_recognition.load_image_file("/home/ma27/me.jpg")
>>> print(face_recognition.face_locations(img))
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.


propagatedBuildInputs = [ pillow click dlib numpy face_recognition_models scipy ];

doCheck = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, they're not available with pypi, moving to fetchFromGitHub + active tests, just did some fast bootstrapping in an isolated environment, but you're right, active tests are way better %)

sha256 = "1kwnv3qpy5bhspk780bkyg8jd9n5f6p91ja6sjlwk1wcm00d56xp";
};

# no module named `tests`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are simply no tests: https://github.com/ageitgey/face_recognition_models


meta = with stdenv.lib; {
license = licenses.mit;
homepage = https://pypi.python.org/pypi/face_recognition;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license = licenses.mit;
homepage = https://pypi.python.org/pypi/face_recognition;
maintainers = with maintainers; [ ma27 ];
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description is missing

doCheck = false;

meta = with stdenv.lib; {
homepage = https://pypi.python.org/pypi/face_recognition_models;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

homepage = https://pypi.python.org/pypi/face_recognition_models;
license = licenses.cc0;
maintainers = with maintainers; [ ma27 ];
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description missing

@Ma27
Copy link
Member Author

Ma27 commented Mar 21, 2018

@dotlambda thanks a lot for the feedback, added tests for face_recognition, tested everything in a sandbox, should be fine now %)

@dotlambda
Copy link
Member

@GrahamcOfBorg build python2.pkgs.face_recognition python3.pkgs.face_recognition

pname = "face_recognition";
version = "1.2.1";

src = fetchFromGitHub {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a comment why you're fetching from GitHub, and maybe open an upstream issue about missing tags.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ma27 Did you open an issue?

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: python2.pkgs.face_recognition, python3.pkgs.face_recognition

Partial log (click to expand)

test_raw_face_landmarks (tests.test_face_recognition.Test_face_recognition) ... ok
test_raw_face_locations (tests.test_face_recognition.Test_face_recognition) ... ok
test_raw_face_locations_32bit_image (tests.test_face_recognition.Test_face_recognition) ... ok
test_raw_face_locations_batched (tests.test_face_recognition.Test_face_recognition) ... ok

----------------------------------------------------------------------
Ran 22 tests in 285.080s

OK
error: build of '/nix/store/9bq6i0afkjj520z8820ln4sjgllh2v66-python3.6-face_recognition-1.2.1.drv' failed

@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Attempted: python2.pkgs.face_recognition, python3.pkgs.face_recognition

Partial log (click to expand)

test_raw_face_landmarks (tests.test_face_recognition.Test_face_recognition) ... ok
test_raw_face_locations (tests.test_face_recognition.Test_face_recognition) ... ok
test_raw_face_locations_32bit_image (tests.test_face_recognition.Test_face_recognition) ... ok
test_raw_face_locations_batched (tests.test_face_recognition.Test_face_recognition) ... ok

----------------------------------------------------------------------
Ran 22 tests in 665.386s

OK
�[31;1merror:�[0m build of '/nix/store/lcpv8vq6vypzlvyishgs2fkvx7igc637-python3.6-face_recognition-1.2.1.drv' failed

Adds the python package `face_recognition` and its dependency
`face_recognition_models`.

This package is a wrapper for `dlib` which is able to detect faces in a
given image. I checked the package with the following expression:

```
with import ./. { };

stdenv.mkDerivation {
  name = "facetest";
  src = null;
  buildInputs = with pythonPackages; [ face_recognition ];
}
```

The package works perfectly fine in a `nix-shell`:

```
$ nix-shell
[nix-shell:~]$ python
Python 2.7.14 (default, Sep 16 2017, 17:49:51)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import face_recognition
>>> img = face_recognition.load_image_file("/home/ma27/me.jpg")
>>> print(face_recognition.face_locations(img))
```
@Ma27
Copy link
Member Author

Ma27 commented Mar 21, 2018

@dotlambda on python3 it was needed to set LC_ALL properly, tests passing locally now %)

@dotlambda
Copy link
Member

@GrahamcOfBorg build python2.pkgs.face_recognition python3.pkgs.face_recognition

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: python2.pkgs.face_recognition, python3.pkgs.face_recognition

Partial log (click to expand)

.
.
.
.
                    [100%]


========================== 22 passed in 85.85 seconds ==========================
/nix/store/ln3qphxg050g4rwky4rhb6q0xdc7q8sx-python2.7-face_recognition-1.2.1
/nix/store/fazsa9w1bc8amlcx62825gx1wr175mxp-python3.6-face_recognition-1.2.1

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: python2.pkgs.face_recognition, python3.pkgs.face_recognition

Partial log (click to expand)

collected 22 items

tests/test_face_recognition.py ......................                    [100%]

========================= 22 passed in 636.35 seconds ==========================
tests/test_face_recognition.py ......................                    [100%]

========================= 22 passed in 640.29 seconds ==========================
/nix/store/4qqn9xkas96rx18mizy8na3pr8v4s72k-python2.7-face_recognition-1.2.1
/nix/store/czfwr3yfnn6k7qjkmixp2kpmirqk1wnf-python3.6-face_recognition-1.2.1

@dotlambda
Copy link
Member

I tested this shortly and encountered

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 21: ordinal not in range(128)

when using Python 2. There was no problem with Python 3. Did you test both versions?

@Ma27
Copy link
Member Author

Ma27 commented Mar 22, 2018

when using Python 2. There was no problem with Python 3. Did you test both versions?

Yes I did (see the results of the REPL session I copied into the commit message). I actually use this library on a simple test project with Python 2.7 and the current derivation lives in my local Nix store (built with sandbox enabled).
Can you give me a precise guidance to reproduce this issue?

Did you open an issue?

ageitgey/face_recognition#417

@dotlambda dotlambda merged commit 1aedde9 into NixOS:master Mar 23, 2018
@Ma27 Ma27 deleted the init-face-recognition branch March 26, 2018 15:52
@Ma27
Copy link
Member Author

Ma27 commented Apr 2, 2018

just to document it here: upstream will create git tags for their releases from now on, so with the next bump we can get rid of using revs that point to PyPI releases (ageitgey/face_recognition#417 (comment))

Ma27 added a commit to Ma27/nixpkgs that referenced this pull request Apr 3, 2018
The following fixes have been applied according to the changelog (https://github.com/ageitgey/face_recognition/releases)

- Added the face_detection CLI command
- Removed dependencies on scipy to make installation easier
- Cleaned up KNN example and fixed a bug with drawing fonts to label detected faces in the demo

Furthermore the maintainer switched to actual GIT tags for PyPI releases
as discussed in ageitgey/face_recognition#417 and NixOS#37566
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants