This was a while ago, so I don’t remember exactly what I did. The way I wrote my script was a for loop of all my data and kept only the data that had a valid annotations. E.g. whether the annotations contained a bounding box or a particular class. If you this doesn’t help, I can have a look for the script I wrote and upload it for you.