Code Monkey home page Code Monkey logo

multihypothesestracking's Introduction

Multi Hypothesis Tracking

originally developed by Carsten Haubold, 2015; maintained by the ilastik team.

This is a standalone tool for running tracking of divisible objects, with competing detection hypotheses in each frame. When specifying a ground truth labeling for a dataset, the weights can be learned using structured learning (by OpenGM's implementation of SBMRM). The tracking problem is then solved as ILP by Gurobi or CPLEX, depending on how this tool was compiled.

Installation

Conda

You can install the python module of this package within a conda environment using one of the following lines, depending on whether you locally have CPLEX or GUROBI installed.

CPLEX_ROOT_DIR=/path/to/my/CPLEX/ conda install multi-hypotheses-tracking-with-cplex -c chaubold -c ilastik
GUROBI_ROOT_DIR=/path/to/my/Gurobi/mac64 conda install multi-hypotheses-tracking-with-gurobi -c chaubold -c ilastik

Manual compilation

Requirements:

If you want to parse the JSON files with comments, use e.g. commentjson for python, or Jackson for Java.

Binaries

The bin folder contains the tools that can be run from the command line. All of the tools use JSON file formats as input and output (see below). Invoke them once to see usage instructions.

  • train: given a graph and the corresponding ground truth, return the best weights
  • track: given a graph and weights, return the best tracking result
  • validate: given a graph and a solution, check whether it violates any constraints (useful when creating a ground truth)
  • printgraph: given a graph (and optionally a solution), draw the graph with graphviz dot (see below)

Example:

$ ls
>>> gt.json	track	Makefile	model.json	train

$ ./train -m model.json -g gt.json -w weights.json
>>> lots of output...

$ ./track -m model.json -w weights.json -o trackingresult.json
>>> lots of output...

$ ./validate -m model.json -s trackingresult.json
>>> ...output...
>>> Is solution valid? yes

$ ./printgraph -m model.json -s trackingresult.json -o mygraph.dot
$ dot -Tpdf mygraph.dot > mygraph.pdf
$ open mygraph.pdf

Or if you want to use it from python, you can create the model and weight as dictionaries (exactly same structure as the JSON format) and then in python run the following:

import multiHypoTracking_with_gurobi as mht

# run tracking
mymodel = {...}
myweights = {"weights": [10,10,500,500]}
result = mht.track(mymodel, myweights)

# run structured learning
myresults = {...}
learnedweights = mht.track(mymodel, myresults)

See test/test.py for a complete example.

JSON file formats

  • Ids: every segmentation/detection hypotheses must get its own unique ID by which it is referenced throughout the model and ground truth. An ID is a size_t (unsigned long) by default, but by configuring the WITH_STRING_IDS flag in ccmake one can switch to strings. The provided conda packages use numbers and not strings.
  • Graph description: test/magic.json
    • there are two ways how weights and features work together: the same weight can be used as multiplier on the i'th feature but for different states, or different weights are used for each and every feature and state. This is controlled by specifying "statesShareWeights".
    • each feature vector is supposed to be a list of lists, where there are as many inner lists as the variable can take states
    • an arbitrary number of features allowed inside the inner list [] per state
    • it can help to add a constant feature (=1) to the list, so one weight can act as a bias (the other weights define the normal vector of a decision plane in hyperspace)
    • each segmentation hypothesis can have the optional attributes divisionFeatures, appearanceFeatures and disappearanceFeatures. For each of the given attributes, a special variable will be added to the optimization problem. If these features are not given, then the segmentation hypothesis is not allowed to divide, appear or disappear, respectively.
  • Tracking Result = Ground Truth format: test/gt.json
    • only positive links are required to be set, omitted links are assumed to be "false"
    • same for divisions, only active divisions need to be recorded
  • Weight format: test/weights.json

Dot output

(requires graphviz to be installed, on OSX using e.g. homebrew this can be done by brew install graphviz)

After calling Model::toDot(filename, solution), or running the printgraph tool, the resulting *.dot file can be transformed to e.g. PDF by invoking:

dot -Tpdf result.dot > result.pdf

The graph should then look as below, where blue nodes and edges indicate that they were used in the solution, black ones are unused, and red edges display mutual exclusions. Result Graph

multihypothesestracking's People

Contributors

chaubold avatar k-dominik avatar stuarteberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multihypothesestracking's Issues

C++ Error

Hi,

I have a question about exceptions from the C++ layer. I'm running the test script which is giving error messages like:

res = mht.track(graph, weights)
RuntimeError: unidentifiable C++ exception

Here there is something going wrong at the C++ layer, but there's no information at the python layer. Is there any way to make sure that C++ exceptions get clearly communicated to the python layer? Without further information, it's kind of hard to debug this. Has anyone seen this before, or does anyone have an idea what could be going on?

Thanks!

future of this repo

Dear @chaubold,

i noticed that our fork in the ilastik org diverged a bit from your repo. In a way I think it would be best to transfer this repository to the ilastik org, since we still use and maintain it. What do you think? Alternatively we could try to always add our changes upstream here...

Cheers
Dominik

gurobi not found on osx

per user report, and I could also reproduce this, the current version shipped in ilastik (at least 1.4.1b6 - 1.4.1b13) does not properly pick up gurobi, even after adding symlinks.

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.