Skip to content

Commit

Permalink
Fix possible bw issue in exportable code (#2212)
Browse files Browse the repository at this point in the history
* Fix backward compatibility of exportable code

* Update exportable code reqs

* Fix black
  • Loading branch information
sovrasov authored May 31, 2023
1 parent 216ed83 commit b987ecd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion otx/api/usecases/exportable_code/demo/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
openvino==2022.3.0
openmodelzoo-modelapi==2022.3.0
otx==1.2.3
otx @ git+https://github.com/openvinotoolkit/training_extensions/@3743a92784f6c2c0e5a4a0a836d4ec7696451b9c#egg=otx
numpy>=1.21.0,<=1.23.5 # np.bool was removed in 1.24.0 which was used in openvino runtime
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ class DetectionToAnnotationConverter(IPredictionToAnnotationConverter):
def __init__(self, labels: Union[LabelSchemaEntity, List], configuration: Optional[Dict[str, Any]] = None):
self.labels = labels.get_labels(include_empty=False) if isinstance(labels, LabelSchemaEntity) else labels
self.label_map = dict(enumerate(self.labels))
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
self.confidence_threshold = configuration["confidence_threshold"]
self.use_ellipse_shapes = False
self.confidence_threshold = 0.0
if configuration is not None:
if "use_ellipse_shapes" in configuration:
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
if "confidence_threshold" in configuration:
self.confidence_threshold = configuration["confidence_threshold"]

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

def __init__(self, labels: LabelSchemaEntity, configuration: Optional[Dict[str, Any]] = None):
self.labels = labels.get_labels(include_empty=False)
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
self.confidence_threshold = configuration["confidence_threshold"]
self.use_ellipse_shapes = False
self.confidence_threshold = 0.0
if configuration is not None:
if "use_ellipse_shapes" in configuration:
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
if "confidence_threshold" in configuration:
self.confidence_threshold = configuration["confidence_threshold"]

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

def __init__(self, labels: LabelSchemaEntity, configuration: Optional[Dict[str, Any]] = None):
self.labels = labels.get_labels(include_empty=False)
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
self.confidence_threshold = configuration["confidence_threshold"]
self.use_ellipse_shapes = False
self.confidence_threshold = 0.0
if configuration is not None:
if "use_ellipse_shapes" in configuration:
self.use_ellipse_shapes = configuration["use_ellipse_shapes"]
if "confidence_threshold" in configuration:
self.confidence_threshold = configuration["confidence_threshold"]

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

0 comments on commit b987ecd

Please sign in to comment.