From 8960b02f5ac6884bd3c0aebeda2e37b9631d8807 Mon Sep 17 00:00:00 2001 From: Ben Hoff Date: Thu, 31 Oct 2019 09:17:21 -0400 Subject: [PATCH] fix serialize bug when using AutoAnnotation runner (#810) --- utils/auto_annotation/run_model.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/utils/auto_annotation/run_model.py b/utils/auto_annotation/run_model.py index b4ef27ecb2b..d791eb09295 100644 --- a/utils/auto_annotation/run_model.py +++ b/utils/auto_annotation/run_model.py @@ -111,6 +111,20 @@ def main(): from cvat.apps.engine.serializers import LabeledDataSerializer + # NOTE: We're actually using `run_inference_engine_annotation` + # incorrectly here. The `mapping` dict is supposed to be a mapping + # of integers -> integers and represents the transition from model + # integers to the labels in the database. We're using a mapping of + # integers -> strings. For testing purposes, this shortcut is fine. + # We just want to make sure everything works. Until, that is.... + # we want to test using the label serializer. Then we have to transition + # back to integers, otherwise the serializer complains about have a string + # where an integer is expected. We'll just brute force that. + + for shape in results['shapes']: + # Change the english label to an integer for serialization validation + shape['label_id'] = 1 + serializer = LabeledDataSerializer(data=results) if not serializer.is_valid():