Skip to content

Commit

Permalink
Merge branch 'main' into rgangire/ood_detection_trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeshgangireddy committed Oct 24, 2024
2 parents 7c951c7 + 115fa13 commit 5937026
Show file tree
Hide file tree
Showing 16 changed files with 375 additions and 317 deletions.
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
# v2.5.0 Intel® Geti™ SDK (22-10-2024)
## What's Changed
* Introduce `delete_dataset` method by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/489
* Update the download_all method for ImageClient to download specific dataset by @rajeshgangireddy in https://github.com/openvinotoolkit/geti-sdk/pull/484
* Update media info schema to include extension by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/494
* Project access refactoring by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/481
* Images upload from list optimization by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/495
* Add readthedocs configuration file by @ljcornel in https://github.com/openvinotoolkit/geti-sdk/pull/497
* Fix bug with label name mapping for hierarchical classification models by @ljcornel in https://github.com/openvinotoolkit/geti-sdk/pull/498
* Introduce new `Anomaly` task by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/487
* Implement `get_training_dataset` method in `DatasetClient` by @ljcornel in https://github.com/openvinotoolkit/geti-sdk/pull/492
* Fix anomaly task title by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/499
* Anomaly tasks backwards compatibility by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/502
* Fix anomaly demo test by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/501
* Introduce project removal delay for short tests by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/500
* Update datumaro requirement from ==1.8.* to ==1.9.* in /requirements by @dependabot in https://github.com/openvinotoolkit/geti-sdk/pull/496
* Update pytest requirement from ==8.2.* to ==8.3.* in /requirements by @dependabot in https://github.com/openvinotoolkit/geti-sdk/pull/482
* Fix organization id fetching by @ljcornel in https://github.com/openvinotoolkit/geti-sdk/pull/504
* Update ModelGroup data model by @ljcornel in https://github.com/openvinotoolkit/geti-sdk/pull/506
* Update Model data model by @ljcornel in https://github.com/openvinotoolkit/geti-sdk/pull/508
* Update pillow requirement from ==10.4.* to ==11.0.* in /requirements by @dependabot in https://github.com/openvinotoolkit/geti-sdk/pull/507
* Fix label assignment for deployed models by @ljcornel in https://github.com/openvinotoolkit/geti-sdk/pull/505

## New Contributors
* @rajeshgangireddy made their first contribution in https://github.com/openvinotoolkit/geti-sdk/pull/484

**Full Changelog**: https://github.com/openvinotoolkit/geti-sdk/compare/v2.3.0...v2.5.0


# v2.3.0 Intel® Geti™ SDK (03-09-2024)
## What's Changed
* Add method to purge models by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/468
* Fix visualization in 008 example notebook by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/472
* Update the Model schema to include the `total_disk_size` field by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/471
* Add support for Credit System API by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/473
* Implement Platform version check by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/474
* Allow Credit System-less servers to authenticate with a token by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/476
* Empty label visualization fix by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/480


**Full Changelog**: https://github.com/openvinotoolkit/geti-sdk/compare/v2.2.0...v2.3.0


# v2.2.0 Intel® Geti™ SDK (18-07-2024)
## What's Changed
* Add `description` attribute to the job class by @igor-davidyuk in https://github.com/openvinotoolkit/geti-sdk/pull/448
Expand Down
2 changes: 1 addition & 1 deletion geti_sdk/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions
# and limitations under the License.

__version__ = "2.3.0"
__version__ = "2.5.0"
3 changes: 2 additions & 1 deletion geti_sdk/data_models/containers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# noqa: D104

from .algorithm_list import AlgorithmList
from .label_list import LabelList
from .media_list import MediaList

__all__ = ["AlgorithmList", "MediaList"]
__all__ = ["AlgorithmList", "MediaList", "LabelList"]
128 changes: 128 additions & 0 deletions geti_sdk/data_models/containers/label_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Copyright (C) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.

from collections import UserList
from typing import Any, Dict, List, Optional, Sequence

from geti_sdk.data_models.label import Label, ScoredLabel
from geti_sdk.data_models.project import Project
from geti_sdk.utils.serialization_helpers import deserialize_dictionary


class LabelList(UserList):
"""
A list containing labels for an Intel® Geti™ inference model.
"""

def __init__(self, data: Optional[Sequence[Label]] = None):
self.data: List[Label] = []
if data is not None:
super().__init__(list(data))

self._id_mapping: Dict[str, Label] = {}
self._name_mapping: Dict[str, Label] = {}
self._generate_indices()
self._empty_label = next((x for x in self.data if x.is_empty), None)

@property
def has_empty_label(self) -> bool:
"""
Return True if the list of Labels contains an empty label
"""
return self._empty_label is not None

def _generate_indices(self):
"""
Map names and ID's to Label objects to enable quick label retrieval
"""
self._id_mapping = {x.id: x for x in self.data}
self._name_mapping = {x.name: x for x in self.data}

def get_by_id(self, id: str) -> Label:
"""
Return the Label object with ID corresponding to `id`
"""
label = self._id_mapping.get(id, None)
if label is None:
raise KeyError(f"Label with id `{id}` was not found in the LabelList")
return label

def get_by_name(self, name: str) -> Label:
"""
Return the Label object named `name`
"""
label = self._name_mapping.get(name, None)
if label is None:
raise KeyError(f"Label named `{name}` was not found in the LabelList")
return label

@classmethod
def from_json(cls, input_json: List[Dict[str, Any]]) -> "LabelList":
"""
Create a LabelList object from json input. Input should be formatted as a list
of dictionaries, each representing a single Label
"""
label_list: List[Label] = []
for item in input_json:
label_list.append(deserialize_dictionary(item, Label))
return cls(label_list)

def create_scored_label(self, id_or_name: str, score: float) -> ScoredLabel:
"""
Return a ScoredLabel object corresponding to the label identified by
`id_or_name`, and with an assigned probability score of `score`
:param id_or_name: ID or name of the Label to assign
:param score: probability score of the label
"""
try:
label = self.get_by_id(id_or_name)
except KeyError:
label = self.get_by_name(id_or_name)
return ScoredLabel.from_label(label, probability=score)

def get_empty_label(self) -> Optional[Label]:
"""
Return the empty label, if the LabelList contains one. If not, return None
"""
return self._empty_label

def get_non_empty_labels(self) -> "LabelList":
"""
Return all non-empty labels
"""
return LabelList([x for x in self.data if not x.is_empty])

@classmethod
def from_project(cls, project: Project, task_index: int = 0) -> "LabelList":
"""
Create a LabelList object for the 'project', corresponding to the trainable
task addressed by `task_index`
:param project: Project for which to get the list of labels
:param task_index: Index of the task for which to get the list of labels.
Defaults to 0, i.e. the first trainable task in the project
"""
task = project.pipeline.trainable_tasks[task_index]
return cls(task.labels)

def sort_by_ids(self, label_ids: List[str]):
"""
Sort the labels in the LabelList by their ID, according to the order defined
in `label_ids`
"""
new_data: List[Label] = []
for label_id in label_ids:
new_data.append(self.get_by_id(label_id))
self.data = new_data
2 changes: 1 addition & 1 deletion geti_sdk/data_models/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import attr

from geti_sdk.data_models.containers import MediaList
from geti_sdk.data_models.containers.media_list import MediaList
from geti_sdk.data_models.enums import SubsetPurpose
from geti_sdk.data_models.media import Image, VideoFrame
from geti_sdk.data_models.utils import (
Expand Down
4 changes: 3 additions & 1 deletion geti_sdk/data_models/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ class ScoredLabel:

_identifier_fields: ClassVar[List[str]] = ["id"]

probability: float
probability: float = attr.field(converter=float) # float converter here to make
# sure we're storing probability
# as a float64 dtype
name: Optional[str] = None
color: Optional[str] = None
id: Optional[str] = None
Expand Down
51 changes: 0 additions & 51 deletions geti_sdk/data_models/label_group.py

This file was deleted.

65 changes: 0 additions & 65 deletions geti_sdk/data_models/label_schema.py

This file was deleted.

1 change: 1 addition & 0 deletions geti_sdk/data_models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class BaseModel:
) # Added in Intel Geti 1.1
total_disk_size: Optional[int] = None # Added in Intel Geti 2.3
training_framework: Optional[TrainingFramework] = None # Added in Intel Geti 2.5
learning_approach: Optional[str] = None # Added in Intel Geti v2.6

def __attrs_post_init__(self):
"""
Expand Down
1 change: 1 addition & 0 deletions geti_sdk/data_models/model_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ModelGroup:
models: List[ModelSummary] = attr.field(repr=False)
task_id: Optional[str] = attr.field(default=None)
id: Optional[str] = attr.field(default=None)
learning_approach: Optional[str] = attr.field(default=None) # Added in Geti v2.5

def __attrs_post_init__(self) -> None:
"""
Expand Down
Loading

0 comments on commit 5937026

Please sign in to comment.