Skip to content

Commit b987ecd

Browse files
authored
Fix possible bw issue in exportable code (#2212)
* Fix backward compatibility of exportable code * Update exportable code reqs * Fix black
1 parent 216ed83 commit b987ecd

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
openvino==2022.3.0
22
openmodelzoo-modelapi==2022.3.0
3-
otx==1.2.3
3+
otx @ git+https://github.com/openvinotoolkit/training_extensions/@3743a92784f6c2c0e5a4a0a836d4ec7696451b9c#egg=otx
44
numpy>=1.21.0,<=1.23.5 # np.bool was removed in 1.24.0 which was used in openvino runtime

otx/api/usecases/exportable_code/prediction_to_annotation_converter.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ class DetectionToAnnotationConverter(IPredictionToAnnotationConverter):
6161
def __init__(self, labels: Union[LabelSchemaEntity, List], configuration: Optional[Dict[str, Any]] = None):
6262
self.labels = labels.get_labels(include_empty=False) if isinstance(labels, LabelSchemaEntity) else labels
6363
self.label_map = dict(enumerate(self.labels))
64-
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
65-
self.confidence_threshold = configuration["confidence_threshold"]
64+
self.use_ellipse_shapes = False
65+
self.confidence_threshold = 0.0
66+
if configuration is not None:
67+
if "use_ellipse_shapes" in configuration:
68+
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
69+
if "confidence_threshold" in configuration:
70+
self.confidence_threshold = configuration["confidence_threshold"]
6671

6772
def convert_to_annotation(
6873
self, predictions: np.ndarray, metadata: Optional[Dict[str, np.ndarray]] = None
@@ -424,8 +429,13 @@ class MaskToAnnotationConverter(IPredictionToAnnotationConverter):
424429

425430
def __init__(self, labels: LabelSchemaEntity, configuration: Optional[Dict[str, Any]] = None):
426431
self.labels = labels.get_labels(include_empty=False)
427-
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
428-
self.confidence_threshold = configuration["confidence_threshold"]
432+
self.use_ellipse_shapes = False
433+
self.confidence_threshold = 0.0
434+
if configuration is not None:
435+
if "use_ellipse_shapes" in configuration:
436+
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
437+
if "confidence_threshold" in configuration:
438+
self.confidence_threshold = configuration["confidence_threshold"]
429439

430440
def convert_to_annotation(self, predictions: tuple, metadata: Dict[str, Any]) -> AnnotationSceneEntity:
431441
"""Convert predictions to OTX Annotation Scene using the metadata.
@@ -492,8 +502,13 @@ class RotatedRectToAnnotationConverter(IPredictionToAnnotationConverter):
492502

493503
def __init__(self, labels: LabelSchemaEntity, configuration: Optional[Dict[str, Any]] = None):
494504
self.labels = labels.get_labels(include_empty=False)
495-
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
496-
self.confidence_threshold = configuration["confidence_threshold"]
505+
self.use_ellipse_shapes = False
506+
self.confidence_threshold = 0.0
507+
if configuration is not None:
508+
if "use_ellipse_shapes" in configuration:
509+
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
510+
if "confidence_threshold" in configuration:
511+
self.confidence_threshold = configuration["confidence_threshold"]
497512

498513
def convert_to_annotation(self, predictions: tuple, metadata: Dict[str, Any]) -> AnnotationSceneEntity:
499514
"""Convert predictions to OTX Annotation Scene using the metadata.

0 commit comments

Comments
 (0)