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

Labellers Refactoring #625

Merged
merged 17 commits into from Aug 27, 2015

Conversation

Projects
None yet
3 participants
@patricksnape
Contributor

patricksnape commented Aug 25, 2015

This addresses #616 and is a big breaking change - I didn't deprecate any of the old label methods to keep the code clean.

Now, labellers can be applied to PointCloud, LandmarkGroup and ndarray. Also, rename all the label methods so that they have a very well-defined structure of object_label_npoints_to_object_label_npoints. This included creating a set of subpackages in menpo.landmark.labels so that everything is much more nicely arranged.

I also snuck in a new overload on MaskedImage which lets you pass mask as a kwarg to init_from_rolled_channels.

from menpo.landmark import face_ibug_68_to_face_ibug_68, labeller
import menpo.io as mio

im = mio.import_image('/vol/atlas/databases/lfpw/trainset/image_0017.png')

# Works on PointClouds
new_pcloud = face_ibug_68_to_face_ibug_68(im.landmarks['PTS'].lms)

# Works on ndarrays
new_pcloud = face_ibug_68_to_face_ibug_68(im.landmarks['PTS'].lms.points)

# Works on LandmarkGroup
new_lmark_group = face_ibug_68_to_face_ibug_68(im.landmarks['PTS'])

# Labeller still works
labeller(im, 'PTS', face_ibug_68_to_face_ibug_68)

patricksnape added some commits Aug 24, 2015

Add init_from_rolled_channels overload for Masked
Enable you to set the mask, which is very useful.
Move labels into a structured format
Split labels between object type e.g. car, human. Then human
is split into subcategories like face, hand, pose etc. This
helps a lot with organization and will allow us to expand more
easily.
Add name_of_callable to Menpo
Stolen from menpofit, very handy function for grabbing the string
name of a callable or function.
Add new static constructor to LandmarkGroup
Build landmark group from indices rather than masks - easier
for specifying labellers.
Add new _labeller decorator
This decorator handles the new workflow for labelling methods.

Labelling functions should return
a template pointcloud and a mapping dictionary (from labels to indices).
This decorator then takes that output and returns the correctly labelled
object depending on if a landmark group, pointcloud or numpy array is
passed.

If a LandmarkGroup was passed, a LandmarkGroup is
returned. This landmark group will contain specific labels and
these labels may refer to sub-pointclouds with specific connectivity
information.

If a PointCloud was passed, a PointCloud is returned. Only
the connectivity information is propagated to the pointcloud
(a subclass of PointCloud may be returned).
Update the ibug_face_68 landmarks to new scheme
Now uses the _labeller decorator. Also, renamed it to match
menpobench since I think @jabooth had decided this was the most
sensible naming scheme. Can be easily renamed! For example,
we may want to use the optional argument on _labeller to make
the group label key shorter!

Also, update the labeller method to grab the group label off of
the function itself. All the other methods are thus broken at
the moment, but this is a work in progress.
Refactoring labels (take parameter)
Change the _labeller decorator a bit, to take an extra kwarg
that can return the mapping dict, if a PointCloud was passed.
This is useful for reusing annotation schemes.

Also, make the wrapped methods take an argument to allow for
formats that reduce the number of annotations.

Also, simplify the output labels by just taking the back half
of the name scheme.

This was then applied to all of the label functions we have.
Fix documentation for labels/landmarks
Also, make sure everything is exposed properly in the landmark
package
Fix docs for other new methods
This includes recently added new methods which are now exposed.
Fixed broken import for test
Removed unnecessary labelling
@nontas

This comment has been minimized.

Member

nontas commented Aug 27, 2015

Very useful addition! +1

patricksnape added some commits Aug 27, 2015

Move mesh to face_3d
As suggested by @nontas
Add tests - fix Human pose bug!
Tests now test the naming scheme - found a bug in one of the
humanpose labels
Bug in Python 3 - zip as list
Convert zip to list otherwise generators cannot be concatenated
More zip to list for Python 3
Hopefully that is all of them
@nontas

This comment has been minimized.

Member

nontas commented Aug 27, 2015

Tests passed so I merge this in

nontas added a commit that referenced this pull request Aug 27, 2015

@nontas nontas merged commit 6dc5b90 into menpo:master Aug 27, 2015

4 checks passed

OS X MenpoBot Jenkins build passed No test results found.
Details
clahub All contributors have signed the Contributor License Agreement.
Details
continuous-integration/appveyor AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jabooth jabooth removed the in progress label Aug 27, 2015

@nontas nontas deleted the patricksnape:labellers branch Aug 27, 2015

@patricksnape patricksnape referenced this pull request Sep 1, 2015

Closed

refactor labels #616

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment