Home

Awesome

GASP

Generalized Algorithm for Signed graph Partitioning

Installation

<!-- - Create conda environment and install the `nifty` and `vigra` packages with: `conda create -n GASP -c abailoni -c conda-forge nifty=1.0.9 vigra affogato=0.2.2`. The source code for the `nifty` package can also be found here: https://github.com/abailoni/nifty - Activate the environment: `source activate GASP` - Clone this repository: `git clone https://github.com/abailoni/GASP.git` - `cd ./GASP` - Install the package: `python setup.py install` - Dependencies to check: h5py - Add arXiv link - <!-- ## CREMI experiments To run GASP, go to the `experiments/CREMI` folder and run the `run_GASP` script: python run_GASP.py /path/to/cremi/dataset/folder --samples A B C --linkage_criteria average --add_cannot_link_constraints false --> <!-- Samples `A`, `B` and `C` correspond to training data. Samples `A+`, `B+` and `C+` correspond to test data. See more details about `linkage_criteria` below. -->

How to use the package

Examples

In the folder examples there are some scripts to run the GASP algorithm directly on a graph or on affinities generated from an image.

Running GASP on a graph

The main function to run GASP on a graph (that can be built using the nifty package) is given by from GASP.segmentation import run_GASP:

run_GASP(
        graph,
        signed_edge_weights,
        linkage_criteria='mean',
        add_cannot_link_constraints=False,
        edge_sizes=None,
        is_mergeable_edge=None,
        use_efficient_implementations=True,
        verbose=False,
        linkage_criteria_kwargs=None,
        print_every=100000)

with the following parameters:

Image segmentation with GASP

For more details about it, see example examples/run_GASP_from_affinities.py and the docstrings of the class GASP.segmentation.GaspFromAffinities:

class GaspFromAffinities(object):
    def __init__(self,
                 offsets,
                 beta_bias=0.5,
                 superpixel_generator=None,
                 run_GASP_kwargs=None,
                 n_threads=1,
                 verbose=False,
                 invert_affinities=False,
                 offsets_probabilities=None,
                 use_logarithmic_weights=False,
                 used_offsets=None,
                 offsets_weights=None):
        ...

     def __call__(self, affinities, *args_superpixel_gen):
        ...