Giter Club home page Giter Club logo

menpobench's Introduction

menpo

PyPI Release BSD License Code style: black
Python 3.6 Support Python 3.7 Support Python 3.8 Support Python 3.9 Support

Menpo. The Menpo Project Python package for handling annotated data.

What is Menpo?

Menpo is a Menpo Project package designed from the ground up to make importing, manipulating and visualizing image and mesh data as simple as possible. In particular, we focus on annotated data which is common within the fields of Machine Learning and Computer Vision. All core types are Landmarkable and visualizing these landmarks is very simple. Since landmarks are first class citizens within Menpo, it makes tasks like masking images, cropping images inside landmarks and aligning images very simple.

Menpo were facial armours which covered all or part of the face and provided a way to secure the top-heavy kabuto (helmet). The Shinobi-no-o (chin cord) of the kabuto would be tied under the chin of the menpo. There were small hooks called ori-kugi or posts called odome located on various places to help secure the kabuto's chin cord.

--- Wikipedia, Menpo

Installation

Here in the Menpo Team, we are firm believers in making installation as simple as possible. Unfortunately, we are a complex project that relies on satisfying a number of complex 3rd party library dependencies. The default Python packing environment does not make this an easy task. Therefore, we evangelise the use of the conda ecosystem, provided by Anaconda. In order to make things as simple as possible, we suggest that you use conda too! To try and persuade you, go to the Menpo website to find installation instructions for all major platforms.

If you feel strongly about using Menpo with the most commonly used Python package management system, pip, then you should be able to install Menpo as follows:

> pip install menpo

We strongly advocate the use of conda which does not require compilation for installing Menpo or it's dependencies such as Numpy, SciPy or Matplotlib. Installation via conda is as simple as

> conda install -c conda-forge menpo

Build Status

And has the added benefit of installing a number of commonly used scientific packages such as SciPy and Numpy as Menpo also makes use of these packages.

CI Host OS Build Status
CircleCI linux/amd64 menpo

Usage

Menpo makes extensive use of Jupyter Notebooks to explain functionality of the package. These Notebooks are hosted in the menpo/menpo-notebooks repository. We strongly suggest that after installation you:

  1. Download the latest version of the notebooks
  2. Conda install Jupyter notebook and IPython: conda install jupyter ipython notebook
  3. Run jupyter notebook
  4. Play around with the notebooks.

Want to get a feel for Menpo without installing anything? You can browse the notebooks straight from the menpo website.

Other Menpo projects

Menpo is designed to be a core library for implementing algorithms within the Machine Learning and Computer Vision fields. For example, we have developed a number of more specific libraries that rely on the core components of Menpo:

  • menpofit: Implementations of state-of-the-art deformable modelling algorithms including Active Appearance Models, Constrained Local Models and the Supervised Descent Method.
  • menpo3d: Useful tools for handling 3D mesh data including visualization and an OpenGL rasterizer. The requirements of this package are complex and really benefit from the use of conda!
  • menpodetect: A package that wraps existing sources of object detection. The core project is under a BSD license, but since other projects are wrapped, they may not be compatible with this BSD license. Therefore, we urge caution be taken when interacting with this library for non-academic purposes.

Documentation

See our documentation on ReadTheDocs

Testing

We use pytest for unit tests.

After installing pytest, mock and pytest-mock, running

>> pytest .

from the top of the repository will run all of the unit tests.

Some small parts of Menpo are only available if the user has some optional dependency installed. These are:

  • 3D viewing methods, only available if menpo3d is installed
  • menpo.feature.dsift only available if cyvlfeat is installed
  • Some warping unit tests are only available if opencv is installed

menpobench's People

Contributors

jabooth avatar patricksnape avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

menpobench's Issues

Decide how to store and return results

menpobench currently goes as far as building and testing methods, gets the fitting results, and then...does nothing with them.

We need to persist the results from a given method. I think a .pkl of all the fitting results should be stored in the menpobench cache, that way at a later date we can recompute different graphs (i.e. handle different normalization formats).

The current design in mind is as follows:

For a given unique combination of: (training_dataset, testing_dataset, method)
or, in the case of untrainable_methods: (testing_dataset, untrainable_method)

if all components are pre-defined, cache the resulting fitting results to the cache/results/hash.pkl. On future invocations, check this cache, and return if it's available. We will also add a predefined cache that ships with menpobench - this will be updated from the continuous integration server, so for most common tests menpobench can complete immediately.

If any component is user defined, we don't use the cache at all. There is a reasonable expectation that these non-predefined files may be modified by the user, and we don't want to accidentally serve a cached result. We could definitely make this more advanced in the future, but for now, KISS.

We then write a generic output generation function that takes a set of fitting results and draws up the curves in various forms (e.g. different normalisation schemes). The user could have to provide an output dir which we populate with:

  1. The pkl of the experiment (regardless of whether the test was predefined or not)
  2. Graphs for commonly used normalisation
  3. CSVs for the above graphs.

A flag could be added to return a mat file if the user wishes to easily import the fitting result data into matlab. With this, we would be heading towards something like:

menpobench ./mytest.yaml -o ./output --mat

With all this the API would look like:

./output
  ./methods
    ./aam
      ./fitting_results.mat
      ./fitting_results.pkl
      ./ced.pdf
      ./ced.csv
    ./sdm
      ...

Add bounding box creation schemes

The code to generate bounding box initialisations should probably live inside menpobench. The two initialisations that interest us from the start are:

  1. Initialise from object detection (to start with from dlib)
  2. Initialise with noise, using the approach of menpofit (post refactor)

For the object detection, we will want to:

  1. Detect bounding boxes using the object detector
  2. Define an measure of 'acceptable performance', based on overlap of gt/detected bounding boxes
  3. If the detection failed, or is below threshold for acceptable performance, a new bounding box will be synthesised
  4. Synthesised bounding boxes are placed by using a learned multivariate gaussian on the acceptable bounding boxes.

@patricksnape @nontas @jalabort Do you agree with this approach? Some help with the following questions would be great:

  1. What do we feel is a good overlap amount? I was thinking that 80% of ground truth is covered by detected?
  2. If there are multiple detections, we just keep one right?
  3. Sorry @jalabort, can you point me once again to the new style noise initialisations in menpofit/refactor?

If we get this sorted I can add lfpw, afw, ibug, and helen datasets to menpobench with detections today. Any other datasets we want for testing?

Finding Matlab

At the moment, we plan on natively supporting Matlab in a thorough manner. Therefore, we need to be able to reliably call out to Matlab. We could just say that users have to sort this themselves, but that is very unfriendly on OSX and Windows where matlab is not on the path by default. We should probably have some sort of logic that tries to work out which Matlab is installed, and if it fails it should fallback to something like the caching mechanism and store it in the .menpobench config file.

We should probably add Matlab existence to YAML validation as well.

Validate the experiment YAML

We should validate the YAML to make sure the user has provided a validate schema. Also, it would be nice to have custom types using something like kwalify where we could even validate the Metadata. This would be particularly useful for something like Matlab support and finding the correct Matlab binary path!

Decide how to calculate errors

One idea is to have another key in the YAML that specifies which error measure gets calculated:

error_function:
  - ibug_68_48_points_face_size

But this may be overly complicated. Perhaps the number of landmarks expected should be handled by another key? Or perhaps normalisation should be separate?

The biggest problem is something like Intraface which only returns 49 points - what if we trained on 68?

Decide on metadata schema

Metadata should come in two forms:

  • Optional metadata - probably in the form of a dictionary
    • description
    • publications
    • any other notes
  • Mandatory metadata
    • 'Pretty' name
    • Supported platforms - {win32, win64, linux32, linux64, osx64, all}

These should be used in conjunction with the yaml for validating an experiment.

datasets should be randomised

The order that assets are loaded from each dataset should be randomised. Furthermore, when drawing from multiple assets, we should randomise which dataset we load from, rather than just chaining them.

support custom modules in output dir

Currently we aren't too careful about the naming of everything in the output directory. If a user runs an experiment with lots of custom modules (e.g. custom dataset, custom lm_processing, custom methods, custom normalisation results) we currently will just hit strange errors in the output. I had a little go at ensuring these problems would be mitigated at least for the error_name here:

        name = '{}_{}'.format(i, Path(error_name).name.replace('.', '_'))

but clearly this requires deeper thought to work for all modules.

Menpobench command to update the config file

You should be able to call something like:

menpobench config cache_dir /my/cache/dir

To update the config values. Particularly useful for things like the Matlab path, in case the automatically detected Matlab path is incorrect.

Use metadata to make output more readable

We currently don't use any of the metadata in making the output results more readable. As a simple example, the display_name_short metadata on methods would be an ideal candidate for use in CED legends and eventually on the website. Problems arise in using this in two areas:

  1. Ensuring uniqueness. This is related to #10. As we move away from predefined keys with guaranteed uniqueness to custom paths and arbitrary strings in metadata, we can run into situations where two methods for instance could have the same short name.
  2. Reloading after failure. Currently CED plotting only depends on the output dir - the actual modules don't have to be present and loaded. This is nice and self contained. Currently no metadata is persisted to the output dir, so we would have to source and reload all original modules to plot output after the fact. Currently we allow relative paths in experiments to other modules, so although we have the original experiment we don't have the modules there to load.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.