How to extract annotations from CVAT XML file generated using SAM model into mask files in Python

73 Views Asked by At

I'm new to CV. I have an annotation XML file generated using the CVAT semi-automated SAM model. May I know how I can load the XML file and extract the object I am interested in as a mask in jupyter notebook environment? I have 4 object classes and 1000 images.

Sample of annotation content
<annotations>
<version>1.1</version>
<meta>
    <job>.....
    <label>
    <name>objectClass1</name>
    <color>#00c44e</color>
    <type>any</type>
    <attributes> </attributes>
    </label>
    ...
    </job>

</meta>
<image id="0" name="KKM22(1).jpg" width="3024" height="4032">
    <mask label="KKM22" source="semi-auto" occluded="0" rle="772, 4, 1609, 40, 1579, 77, 1485, 38,   17, 92, 1459, 172, 1448, 183, 1440, 191, 1434, 197, 1426, 206, 1416, 218, 1403, 234, 1392, 243, 1382,
    .....
</image>

I have tried a couple of times referring to online tutorial but the result I obtained is in the bounding box instead of the mask.

0

There are 0 best solutions below