Code Monkey home page Code Monkey logo

django-labeller's Introduction

django-labeller

A light-weight image labelling tool for Python designed for creating segmentation data sets.

  • compatible with Django and Flask
  • polygon, box, point and oriented ellipse annotations supported
  • polygonal labels can have disjoint regions and can be editing using paintng and boolean operations; provided by polybooljs
  • can use the DEXTR algorithm to automatically generate polygonal outlines of objects identified by the user with a few clicks; provided by the dextr library

Django Labeller in action: Django labeller movie

Django or Flask?

If you want to run django-labeller on your local machine with minimum fuss and store the image and label files on your file system, use the Flask application.

If you want to incorporate django-labeller into your Django application, use the Django app/plugin as it provides model classes that store labels in your database, etc.

Installation

If you to use the example Django application or use the provided example images, clone it from GitHub and install (recommended):

> git clone https://github.com/uea-computer-vision/django-labeller.git
> python setup.py install

To use it as a library, either with Flask or Django, install from PyPI:

> pip install django-labeller

Note:

  • pip install django-labeller[django] will also install the Django dependency
  • pip install django-labeller[dextr] will also install the dextr library

Examples

Flask web app example

An example Flask-based web app is provided that displays the labelling tool within a web page. To start it, change into the same directory into which you cloned the repo and run:

> python -m image_labelling_tool.flask_labeller 

Now open 127.0.0.1:5000 within a browser.

If you want to load images from a different directory, or if you installed from PyPI, tell flask_labeller where to look:

> python -m image_labelling_tool.flask_labeller --images_pat=<images_directory>/*.<jpg|png>

Flask app with DEXTR assisted labelling

First, install the dextr library:

> pip install dextr

Now tell the Flask app to enable DEXTR using the --enable_dextr option:

> python -m image_labelling_tool.flask_labeller --enable_dextr

The above will use the ResNet-101 based DEXTR model trained on Pascal VOC 2012 that is provided by the dextr library. If you want to use a custom DEXTR model that you trained for your purposes, use the --dextr_weights option:

> python -m image_labelling_tool.flask_labeller --dextr_weights=path/to/model.pth

Django web app example

The example Django-based web app provides a little more functionality than the Flask app. It stores the label data in a database (only SQLite in the example) and does basic image locking so that multiple users cannot work on the same image at the same time.

To initialise, first perform migrations:

> python simple_django_labeller/manage.py migrate

Then populate the database with the example images in the images directory (replace images with the path of another directory if you wish to use different images):

> python simple_django_labeller/manage.py populate images

Then run the app:

> python simple_django_labeller/manage.py runserver

Django app with DEXTR assisted labelling

First, install the dextr library and celery:

> pip install dextr
> pip install celery

Now install RabbitMQ, using the appropriate approach for your platform (you could use a different Celery backend if you don't mind editing settings.py as needed).

Enable DEXTR within tests/example_labeller_app/settings.py; change the line

LABELLING_TOOL_DEXTR_AVAILABLE = False

so that LABELLING_TOOL_DEXTR_AVAILABLE is set to True.

You can also change the LABELLING_TOOL_DEXTR_WEIGHTS_PATH option to a path to a custom model, otherwise the default ResNet-101 based U-net trained on Pascal VOC 2012 provided by the dextr library will be used.

Now run the Django application:

> cd simple_django_labeller
> python manage.py runserver

Now start a celery worker:

> cd simple_django_labeller
> celery -A example_labeller_app worker -l info

Note that Celery v4 and above are not strictly compatible with Windows, but it can work if you run:

> celery -A example_labeller_app worker --pool=solo -l info

API and label access

Please see the Jupyter notebook Image labeller notebook.ipynb for API usage. It will show you how to load labels and render them into class maps, instance maps, or image stacks.

Libraries, Credits and License

Incorporates the public domain json2.js library. Uses d3.js, jQuery, popper.js, PolyK, polybooljs and Bootstrap 4.

This software was developed by Geoffrey French in collaboration with Dr. M. Fisher and Dr. M. Mackiewicz at the School of Computing Sciences at the University of East Anglia as part of a project funded by Marine Scotland.

It is licensed under the MIT license.

django-labeller's People

Contributors

britefury avatar gfrenchuea avatar

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.