tflite_model_maker.object_detector.DataLoader

train_data = object_detector.DataLoader.from_pascal_voc(“/content/drive/MyDrive/10ImagesTesting/Train10imagesXML”, “/content/drive/MyDrive/10ImagesTesting/Train10imagesXML”, label_map= {1: “Circle K Donut”, 2: “Chocolate Heart”, 3: “Chocolate Heart With Sprinkles”, 4: “Chocolate Ring”,5: “Chocolate Ring With Sprinkles”, 6: “Apple Turnover”, 7: “Red Velvet Cake”, 8: “Chocolate Old Fashioned”,8: “Chocolate Old Fashioned”, 9: “Concha”, 10: “Crumb Cake”, 11: “Strawberry Heart With Sprinkles promo”,12: “Blueberry Fritter”, 13: “Apple Fritter”, 14: “Cinnamon Roll”, 15: “Frosted Cinnamon Roll”,16: “Butter Croissant”, 17: “Raspberry Filled”, 18: “Boston cream shell”, 19: “Cotton Candy Ring Promo”,20: “Glazed Ring”, 21: “Sugared Ring”, 22: “Glazed Twist”, 23: “Sugared Twist”,24: “Glazed Pull Apart”, 25: “Sprinkled Pull Apart”, 26: “Strawberry Ring With Sprinkles”, 27: “Death by Chocolate”, 28: “Boston Cream Bar”, 29: “Jelly Filled Bar”, 30: “Brownie Batter Bar”, 31: “Chocolate Bar”,32: “Maple Bar”})

ERROR

/usr/local/lib/python3.7/dist-packages/tensorflow_examples/lite/model_maker/third_party/efficientdet/dataset/create_pascal_tfrecord.py in dict_to_tf_example(data, images_dir, label_map_dict, unique_id, ignore_difficult_instances, ann_json_dict)
172 area.append((xmax[-1] - xmin[-1]) * (ymax[-1] - ymin[-1]))
173 classes_text.append(obj[‘name’].encode(‘utf8’))
→ 174 classes.append(label_map_dict[obj[‘name’]])
175 truncated.append(int(obj[‘truncated’]))
176 poses.append(obj[‘pose’].encode(‘utf8’))

KeyError: '23

1 Like

I’m having the same issue. Any luck?
Edit: Just figured it out myself, in the xml files, some files were missing the field. I just added <pose>Undefined</pose> after </name> and got it to work.

1 Like