janfreyberg / superintendent

Practical active learning in python
https://superintendent.readthedocs.io
189 stars 18 forks source link

Bounding box annotation #48

Closed thomassajot closed 4 years ago

thomassajot commented 4 years ago

A useful feature for object detection is to define the bounding box (or even polygon) around one or many objects in an image.

thomassajot commented 4 years ago

Keeping the prediction made by the model on the remaining images would speed up the labelling process. This UI is build using jupyter-innotater image

janfreyberg commented 4 years ago

Hi,

thanks for raising this! I am actually currently working on this. I'm developing the bounding box / polygon interface here: https://ipyannotations.readthedocs.io/en/latest/

For the integration, really the only thing missing is to document it. If you want to try it, you can do:

pip install superintendent ipyannotations

then run this in a notebook:

from ipyannotations import PolygonAnnotator
from superintendent.base import Labeller

input_widget = PolygonAnnotator(classes=["pigeon"])

labeller = Labeller(
    features=["img/vdnkh.jpg"],  # your list of images
    input_widget=input_widget,
    display_func=input_widget.display
)

labeller
thomassajot commented 4 years ago

Hi,

This is great ! I believe the classes argument of PolygonAnnotator should be called options.

Unfortunately I did not manage to display the image.

from ipyannotations import PolygonAnnotator
from superintendent.base import Labeller

input_widget = PolygonAnnotator(options=["pigeon"])

labeller = Labeller(
    features=["my_image.jpg"],
    input_widget=input_widget,
    display_func=input_widget.display
)

labeller

image

Would you know about this issue ?

janfreyberg commented 4 years ago

Yes, you're right, that's a mistake on my side.

I'm not sure why the image is not displaying... is the image stored in the same directory as the notebook you're working in?

And if you have an older version of jupyter notebook installed, you may have to also run this command: jupyter nbextension enable --py --sys-prefix ipycanvas

(see here )

thomassajot commented 4 years ago

Installing the extension solves the display issue. Thanks !

thomassajot commented 4 years ago

There is a subsequent bug. Running the code once creates a labeller.new_labels with one element in the list [None] Running the code a second time, labeller.new_labels is now a list of two elements [None, None]

janfreyberg commented 4 years ago

OK, thanks for letting me know - I'll take a look

janfreyberg commented 4 years ago

I've figured it out, it's a silly bug on my part. I'm pushing a fix now, plus some documentation of this example!

janfreyberg commented 4 years ago

This bug is now fixed (see https://github.com/janfreyberg/superintendent/releases/tag/0.5.1) - make sure to upgrade to the latest version from PyPI. As part of this release I also added documentation for using ipyannotations widgets: https://superintendent.readthedocs.io/en/latest/modularity.html

thomassajot commented 4 years ago

Great ! Thank you for the fix.