Guides

Importing Annotations

You can import your annotations when you create a Dataset. Visual Layer Profiler supports the following two annotations types:

  • Image annotations - Images with class labels
  • Object annotations - Objects annotated with bounding boxes and their corresponding annotations

There are two supported annotations formats:

  • Parquet / CSV annotations
  • Json annotations - in the COCO format

🚧

Limitations:

  1. Please note that as of now, annotations can't be added after a Dataset is created
  2. Use the following file names:
  • Json: annotations.json
  • CSV:
    • image_annotations.csv
    • object_annotations.csv
  • Parquet:
    • image_annotations.parquet
    • object_annotations.parquet

Parquet / CSV annotations

If you like to use a parquet like annotation file, here are a couple of examples for full image class label and bounding box object location and class label. Just put a file with the name image_annotations.parquet and object_annotations.parquet or image_annotations.csv and object_annotations.csv in the root folder of your bucket or tar/zip file with images. Make sure the image filenames under the filename column is pointing to the relative location of the file inside the folder.

import pandas as pd
df = pd.read_parquet('image_annotations.parquet')
df
      filename   		                  label

0     IDX_DF_SIG21341_PlasmasNeg.png  IDX_DF

1     IDX_DF_ALM00324_PlasmasPos.png  IDX_DF

2     IDX_DF_ALM00331_PlasmasPos.png  IDX_DF

3     IDX_DF_ALM00340_PlasmasPos.png  IDX_DF

4     IDX_DF_ALM00355_PlasmasPos.png  IDX_DF

...                                  ...     ...

1375  IDX_RC_ALM04559_PlasmasNeg.png  IDX_RC

1376  IDX_RC_ALM04529_PlasmasPos.png  IDX_RC

1377  IDX_RC_ALM00521_PlasmasNeg.png  IDX_RC

1378  IDX_RC_ALM00534_PlasmasNeg.png  IDX_RC

1379  IDX_RC_ALM00544_PlasmasPos.png  IDX_RC

[1380 rows x 2 columns]                      

For Object annotations:

import pandas as pd
df = pd.read_parquet('object_annotations.parquet')
df
       filename	                                col_x  	row_y 	width 	height 	label   
0      Kitti/raw/training/image_2/006149.png    0	      240	    135	    133	    Car      

1      Kitti/raw/training/image_2/006149.png  	608     169    	59	    43	    Car     

2      Kitti/raw/training/image_2/006149.png  	285     205    	81	    51	    Car      

3      Kitti/raw/training/image_2/006149.png  	187     206    	108		  61	    Car      

4      Kitti/raw/training/image_2/006149.png  	949     162    	226		  70	    Car      

...                              		...	...	...	...	...     

40565  Kitti/raw/training/image_2/001472.png  	726     165	    22	    19	    Van      

40566  Kitti/raw/training/image_2/001472.png  	623     176	    50	    28	    Car     

40567  Kitti/raw/training/image_2/001472.png  	336     118    	185	    106	    Truck     

40568  Kitti/raw/training/image_2/001472.png  	543     177    	115	    63	    Car      

40569  Kitti/raw/training/image_2/001472.png  	577     159    	62	    29	    Tram      

[40570 rows x 7 columns]

Json annotations

To have your annotations imported, you need to:

  • Have them in a single file, named annotations.json
  • Place this file in the root folder of the file you upload or in the S3 bucket you are creating the Dataset from
  • Have the file there when you create the Dataset. For now, you can't import any annotations after you have already created a Dataset.

Here is an example of an annotations file:

Note: "bbox": [col_x,row_y,width,height]. Example: "bbox": [100, 100, 200, 200].

Please make sure you remove the comment for the JSON before importing it to Visual Layer.

{  
        "images": [  
            {  
                "id": 1,  
                "width": 640,  
                "height": 480,  
                "file_name": "image1.jpg"  
            },  
            {  
                "id": 2,  
                "width": 800,  
                "height": 600,  
                "file_name": "image2.jpg"  
            }  
        ],  
        "categories": [  
            {  
                "id": 1,  
                "name": "cat"  
            },  
            {  
                "id": 2,  
                "name": "dog"  
            },  
            {  
                "id": 3,  
                "name": "t-rex"  
            }  
        ],  
        "annotations": [  
            # Two object annotations  
            {  
                "id": 1,  
                "image_id": 1,  
                "category_id": 1,  
                "bbox": [100, 100, 200, 200]  
            },  
            {  
                "id": 2,  
                "image_id": 2,  
                "category_id": 2,  
                "bbox": [50, 50, 150, 150]  
            },  
            # Two image annotations  
            {  
                "id": 3,  
                "image_id": 1,  
                "category_id": 3  
            },  
            {  
                "id": 4,  
                "image_id": 2,  
                "category_id": 3  
            }  
        ]  
    }