ORCNN is an extended Mask R-CNN network with two mask head branches. To be able to train ORCNN, the annotations need to have two masks as well:
- An amodal mask (of the visible and the invisible pixels)
- A visible mask
We recommend the following procedure, using the LabelMe program (https://github.com/wkentaro/labelme):
- For each superclass, make two subclasses using a common separator:
- one class for the amodal masks (separator: [class]_amodal)
- one class for the visible masks (separator: [class]_visible)
- Use distinct group ids, to link the amodal and the visible masks to the same object.
- If a visible mask comprises of two or more separated parts, please use the same group id.
- For both the visible and the amodal masks, please use the following shapes in LabelMe: rectangle, circle, polygon.
This is an example of an amodal and visible mask annotation of two objects of the superclass "broccoli". Each broccoli object has one amodal mask (a red circle with the label "broccoli_amodal") and two visible masks (green polygons that are separated by a leaf, expressed with the labels "broccoli_visible"). To link the multiple masks to the same object, please use distinct group ids (see the (1) and (2) group id behind the annotation).
When the annotations are finished, please convert the annotations to one JSON file that can be processed by ORCNN:
- In a new terminal, activate the virtual environment (for example: conda activate sizecnn)
- Go to the annotation folder (cd /home/[user_name]/sizecnn/annotation, replace [user_name] by your own username)
- Run the python file labelme_to_orcnn.py, using the appropriate arguments (see below):
Argument | Description |
---|---|
--annotation_dir | directory with the images and the annotations |
--write_dir | directory to store the ORCNN images and annotation file |
--amodal_separator | subclass separator of the amodal masks |
--visible_separator | subclass separator of the visible masks |
--description | description of your dataset |
--contributor | your name |
Example (replace [user_name] by your own username):
python labelme_to_orcnn.py --annotation_dir "/home/[user_name]/sizecnn/data/annotations/train" --write_dir "/home/[user_name]/sizecnn/data/orcnn_annotations/train" --classes broccoli apple --amodal_separator _amodal --visible_separator _visible --description broccoli_apple_amodal_visible --contributor PieterBlok
Additional features of the labelme_to_orcnn.py program:
- The program automatically checks whether all images have an annotation and all annotations have an image (if not: an error is raised, and the program is automatically stopped)
- Before starting the conversion, the program checks whether all annotations have at least one amodal and one visible mask (if not: an error is raised, and the program is automatically stopped)
- Before starting the conversion, the program checks whether there are empty group ids (if so: an error is raised, and the program is automatically stopped)
- If no errors in step 1-3, then the conversion is started.
- Besides the above mentioned arguments, you can also input the other arguments:
Argument | Description |
---|---|
--creator_url | this is an URL that is linked to the contributor |
--version | this is the version number of the dataset (input should be an integer!) |
--license_url | this is an URL of the license |
--license_id | this is the identifier of the license |
--license_name | this is the name of the license |