Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/0.4.0][Bug-fix] Convert NaN to num to make visible in geti UI #1413

Merged
merged 3 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions external/anomaly/tasks/openvino.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ def optimize(
if optimization_type is not OptimizationType.POT:
raise ValueError("POT is the only supported optimization type for OpenVINO models")

# Training subset does not contain example of anomalous images.
# Anomalous examples from all dataset used to get statistics for quantization.
dataset = DatasetEntity(
items=[item for item in dataset if item.get_shapes_labels()[0].is_anomalous], purpose=dataset.purpose
)

logger.info("Starting POT optimization.")
data_loader = OTEOpenVINOAnomalyDataloader(config=self.config, dataset=dataset, inferencer=self.inferencer)

Expand Down
2 changes: 1 addition & 1 deletion external/anomaly/tools/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def optimize(self) -> None:

self.openvino_task.optimize(
optimization_type=OptimizationType.POT,
dataset=self.dataset.get_subset(Subset.TRAINING),
dataset=self.dataset,
output_model=optimized_model,
optimization_parameters=OptimizationParameters(),
)
Expand Down
2 changes: 2 additions & 0 deletions external/deep-object-reid/torchreid_tasks/openvino_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from ote_sdk.entities.tensor import TensorEntity
from ote_sdk.entities.resultset import ResultSetEntity
from ote_sdk.entities.result_media import ResultMediaEntity
from ote_sdk.entities.subset import Subset
from ote_sdk.entities.task_environment import TaskEnvironment
from ote_sdk.serialization.label_mapper import LabelSchemaMapper, label_schema_to_bytes
from ote_sdk.usecases.exportable_code.inference import BaseInferencer
Expand Down Expand Up @@ -277,6 +278,7 @@ def optimize(self,
if optimization_type is not OptimizationType.POT:
raise ValueError("POT is the only supported optimization type for OpenVino models")

dataset = dataset.get_subset(Subset.TRAINING)
data_loader = OTEOpenVinoDataLoader(dataset, self.inferencer)

with tempfile.TemporaryDirectory() as tempdir:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from ote_sdk.entities.optimization_parameters import OptimizationParameters
from ote_sdk.entities.result_media import ResultMediaEntity
from ote_sdk.entities.resultset import ResultSetEntity
from ote_sdk.entities.subset import Subset
from ote_sdk.entities.task_environment import TaskEnvironment
from ote_sdk.entities.tensor import TensorEntity
from ote_sdk.entities.label import Domain, LabelEntity
Expand Down Expand Up @@ -589,6 +590,7 @@ def optimize(
"POT is the only supported optimization type for OpenVino models"
)

dataset = dataset.get_subset(Subset.TRAINING)
data_loader = OTEOpenVinoDataLoader(dataset, self.inferencer)

with tempfile.TemporaryDirectory() as tempdir:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from ote_sdk.entities.tensor import TensorEntity
from ote_sdk.entities.resultset import ResultSetEntity
from ote_sdk.entities.result_media import ResultMediaEntity
from ote_sdk.entities.subset import Subset
from ote_sdk.entities.task_environment import TaskEnvironment
from ote_sdk.usecases.evaluation.metrics_helper import MetricsHelper
from ote_sdk.usecases.exportable_code.inference import BaseInferencer
Expand Down Expand Up @@ -252,6 +253,7 @@ def optimize(self,
if optimization_type is not OptimizationType.POT:
raise ValueError("POT is the only supported optimization type for OpenVino models")

dataset = dataset.get_subset(Subset.TRAINING)
data_loader = OTEOpenVinoDataLoader(dataset, self.inferencer)

with tempfile.TemporaryDirectory() as tempdir:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,11 @@ def _generate_training_metrics_group(self, learning_curves) -> Optional[List[Met
return output

for key, curve in learning_curves.items():
metric_curve = CurveMetric(xs=curve.x, ys=curve.y, name=key)
metric_curve = CurveMetric(
xs=np.nan_to_num(curve.x).tolist(),
ys=np.nan_to_num(curve.y).tolist(),
name=key
)
if key == metric_key:
best_acc = max(curve.y)
visualization_info = LineChartInfo(name=key, x_axis_label="Timestamp", y_axis_label=key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,7 @@ def main():
dataset,
environment.get_model_configuration(),
)
openvino_task.optimize(
OptimizationType.POT, dataset.get_subset(Subset.TRAINING), optimized_model, OptimizationParameters()
)
openvino_task.optimize(OptimizationType.POT, dataset, optimized_model, OptimizationParameters())

logger.info("Get predictions on the validation set")
predicted_validation_dataset = openvino_task.infer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ def main(args):
dataset,
environment.get_model_configuration(),
)
openvino_task.optimize(
OptimizationType.POT, dataset.get_subset(Subset.TRAINING), optimized_model, OptimizationParameters()
)
openvino_task.optimize(OptimizationType.POT, dataset, optimized_model, OptimizationParameters())

logger.info("Get predictions on the validation set")
predicted_validation_dataset = openvino_task.infer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,7 @@ def main(args):
dataset,
environment.get_model_configuration(),
)
openvino_task.optimize(
OptimizationType.POT, dataset.get_subset(Subset.TRAINING), optimized_model, OptimizationParameters()
)
openvino_task.optimize(OptimizationType.POT, dataset, optimized_model, OptimizationParameters())

logger.info("Get predictions on the validation set")
predicted_validation_dataset = openvino_task.infer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ def main(args):
dataset,
environment.get_model_configuration(),
)
openvino_task.optimize(
OptimizationType.POT, dataset.get_subset(Subset.TRAINING), optimized_model, OptimizationParameters()
)
openvino_task.optimize(OptimizationType.POT, dataset, optimized_model, OptimizationParameters())

logger.info("Get predictions on the validation set")
predicted_validation_dataset = openvino_task.infer(
Expand Down
2 changes: 1 addition & 1 deletion external/model-preparation-algorithm/submodule
Submodule submodule updated 0 files
5 changes: 1 addition & 4 deletions ote_sdk/ote_sdk/test_suite/training_tests_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,6 @@ class OTETestPotAction(BaseOTETestAction):
_name = "pot"
_depends_stages_names = ["export"]

def __init__(self, pot_subset=Subset.TRAINING):
self.pot_subset = pot_subset

def _run_ote_pot(
self, data_collector, model_template, dataset, environment_for_export
):
Expand All @@ -431,7 +428,7 @@ def _run_ote_pot(
try:
self.openvino_task_pot.optimize(
OptimizationType.POT,
dataset.get_subset(self.pot_subset),
dataset,
self.optimized_model_pot,
OptimizationParameters(),
)
Expand Down