project_name stringlengths 6 104 | file_name stringlengths 4 89 | full_name stringlengths 1 102 | func_name stringlengths 1 85 | docstring stringlengths 13 836 | docstring_tokens listlengths 4 122 | code stringlengths 23 39.7k | code_tokens stringlengths 29 44.6k | url int64 3 986k |
|---|---|---|---|---|---|---|---|---|
openvinotoolkit/training_extensions | model.py | ModelEntity.optimization_methods | optimization_methods | Get or set the optimization methods used on the model. | [
"Get",
"or",
"set",
"the",
"optimization",
"methods",
"used",
"on",
"the",
"model."
] | def optimization_methods(self) -> Optional[List[OptimizationMethod]]:
return self.__optimization_methods | ['def', 'optimization_methods(self)', '->', 'Optional[List[OptimizationMethod]]:', 'return', 'self.__optimization_methods'] | 918,626 |
openvinotoolkit/training_extensions | model.py | ModelEntity.optimization_type | optimization_type | Get or set the optimization type used for the model. | [
"Get",
"or",
"set",
"the",
"optimization",
"type",
"used",
"for",
"the",
"model."
] | def optimization_type(self) -> ModelOptimizationType:
return self.__optimization_type | ['def', 'optimization_type(self)', '->', 'ModelOptimizationType:', 'return', 'self.__optimization_type'] | 918,627 |
openvinotoolkit/training_extensions | model.py | ModelEntity.optimization_objectives | optimization_objectives | Get or set the optimization level of the model. | [
"Get",
"or",
"set",
"the",
"optimization",
"level",
"of",
"the",
"model."
] | def optimization_objectives(self) -> Optional[Dict[str, str]]:
return self.__optimization_objectives | ['def', 'optimization_objectives(self)', '->', 'Optional[Dict[str,', 'str]]:', 'return', 'self.__optimization_objectives'] | 918,628 |
openvinotoolkit/training_extensions | model.py | ModelEntity.performance_improvement | performance_improvement | Get or set the performance improvement of the model. | [
"Get",
"or",
"set",
"the",
"performance",
"improvement",
"of",
"the",
"model."
] | def performance_improvement(self) -> Optional[Dict[str, float]]:
return self.__performance_improvement | ['def', 'performance_improvement(self)', '->', 'Optional[Dict[str,', 'float]]:', 'return', 'self.__performance_improvement'] | 918,629 |
openvinotoolkit/training_extensions | model.py | ModelEntity.exportable_code | exportable_code | Get the exportable_code from the exportable code adapter. | [
"Get",
"the",
"exportable_code",
"from",
"the",
"exportable",
"code",
"adapter."
] | def exportable_code(self) -> Optional[bytes]:
if self.__exportable_code_adapter is not None:
return self.__exportable_code_adapter.data
return None | ['def', 'exportable_code(self)', '->', 'Optional[bytes]:', 'if', 'self.__exportable_code_adapter', 'is', 'not', 'None:', 'return', 'self.__exportable_code_adapter.data', 'return', 'None'] | 918,631 |
openvinotoolkit/training_extensions | model.py | ModelEntity.exportable_code | exportable_code | Set the exportable code using the exportable code adapter. | [
"Set",
"the",
"exportable",
"code",
"using",
"the",
"exportable",
"code",
"adapter."
] | def exportable_code(self, data: Union[bytes, IDataSource]):
self.__exportable_code_adapter = ExportableCodeAdapter(data_source=data) | ['def', 'exportable_code(self,', 'data:', 'Union[bytes,', 'IDataSource]):', 'self.__exportable_code_adapter', '=', 'ExportableCodeAdapter(data_source=data)'] | 918,632 |
openvinotoolkit/training_extensions | model.py | ModelEntity.exportable_code_adapter | exportable_code_adapter | Returns the exportable code adapter. | [
"Returns",
"the",
"exportable",
"code",
"adapter."
] | def exportable_code_adapter(self) -> Optional[ExportableCodeAdapter]:
return self.__exportable_code_adapter | ['def', 'exportable_code_adapter(self)', '->', 'Optional[ExportableCodeAdapter]:', 'return', 'self.__exportable_code_adapter'] | 918,634 |
openvinotoolkit/training_extensions | model.py | ModelEntity.get_data | get_data | Fetches byte data for a certain model. | [
"Fetches",
"byte",
"data",
"for",
"a",
"certain",
"model."
] | def get_data(self, key: str) -> bytes:
return self.__model_adapters[key].data | ['def', 'get_data(self,', 'key:', 'str)', '->', 'bytes:', 'return', 'self.__model_adapters[key].data'] | 918,635 |
openvinotoolkit/training_extensions | model_template.py | HyperParameterData.has_overrides | has_overrides | Returns True if any parameter overrides are defined by the HyperParameters instance, False otherwise. | [
"Returns",
"True",
"if",
"any",
"parameter",
"overrides",
"are",
"defined",
"by",
"the",
"HyperParameters",
"instance,",
"False",
"otherwise."
] | def has_overrides(self) -> bool:
return self.parameter_overrides != {} | ['def', 'has_overrides(self)', '->', 'bool:', 'return', 'self.parameter_overrides', '!=', '{}'] | 918,645 |
openvinotoolkit/training_extensions | model_template.py | ModelTemplate.computes_uncertainty_score | computes_uncertainty_score | Returns true if "compute_uncertainty_score" is in capabilities false otherwise. | [
"Returns",
"true",
"if",
"\"compute_uncertainty_score\"",
"is",
"in",
"capabilities",
"false",
"otherwise."
] | def computes_uncertainty_score(self) -> bool:
return 'compute_uncertainty_score' in self.capabilities | ['def', 'computes_uncertainty_score(self)', '->', 'bool:', 'return', "'compute_uncertainty_score'", 'in', 'self.capabilities'] | 918,649 |
openvinotoolkit/training_extensions | model_template.py | ModelTemplate.computes_representations | computes_representations | Returns true if "compute_representations" is in capabilities. | [
"Returns",
"true",
"if",
"\"compute_representations\"",
"is",
"in",
"capabilities."
] | def computes_representations(self) -> bool:
return 'compute_representations' in self.capabilities | ['def', 'computes_representations(self)', '->', 'bool:', 'return', "'compute_representations'", 'in', 'self.capabilities'] | 918,650 |
openvinotoolkit/training_extensions | model_template.py | ModelTemplate.supports_auto_hpo | supports_auto_hpo | Returns `True` if the algorithm supports automatic hyper parameter optimization, `False` otherwise. | [
"Returns",
"`True`",
"if",
"the",
"algorithm",
"supports",
"automatic",
"hyper",
"parameter",
"optimization,",
"`False`",
"otherwise."
] | def supports_auto_hpo(self) -> bool:
if not self.hyper_parameters.has_valid_configurable_parameters:
return False
auto_hpo_state_results = search_in_config_dict(self.hyper_parameters.data, key_to_search=metadata_keys.AUTO_HPO_STATE)
for result in auto_hpo_state_results:
if str(result[0]).low... | ['def', 'supports_auto_hpo(self)', '->', 'bool:', 'if', 'not', 'self.hyper_parameters.has_valid_configurable_parameters:', 'return', 'False', 'auto_hpo_state_results', '=', 'search_in_config_dict(self.hyper_parameters.data,', 'key_to_search=metadata_keys.AUTO_HPO_STATE)', 'for', 'result', 'in', 'auto_hpo_state_results:... | 918,652 |
openvinotoolkit/training_extensions | resultset.py | ResultSetEntity.model | model | Returns the model that is used for the ResultSet. | [
"Returns",
"the",
"model",
"that",
"is",
"used",
"for",
"the",
"ResultSet."
] | def model(self) -> ModelEntity:
return self.__model | ['def', 'model(self)', '->', 'ModelEntity:', 'return', 'self.__model'] | 918,654 |
openvinotoolkit/training_extensions | resultset.py | ResultSetEntity.prediction_dataset | prediction_dataset | Returns the prediction dataset that is used in the ResultSet. | [
"Returns",
"the",
"prediction",
"dataset",
"that",
"is",
"used",
"in",
"the",
"ResultSet."
] | def prediction_dataset(self) -> DatasetEntity:
return self.__prediction_dataset | ['def', 'prediction_dataset(self)', '->', 'DatasetEntity:', 'return', 'self.__prediction_dataset'] | 918,655 |
openvinotoolkit/training_extensions | resultset.py | ResultSetEntity.ground_truth_dataset | ground_truth_dataset | Returns the ground truth dataset that is used in the ResultSet. | [
"Returns",
"the",
"ground",
"truth",
"dataset",
"that",
"is",
"used",
"in",
"the",
"ResultSet."
] | def ground_truth_dataset(self) -> DatasetEntity:
return self.__ground_truth_dataset | ['def', 'ground_truth_dataset(self)', '->', 'DatasetEntity:', 'return', 'self.__ground_truth_dataset'] | 918,656 |
openvinotoolkit/training_extensions | resultset.py | ResultSetEntity.performance | performance | Returns the performance of the model on the ground truth dataset. | [
"Returns",
"the",
"performance",
"of",
"the",
"model",
"on",
"the",
"ground",
"truth",
"dataset."
] | def performance(self) -> Performance:
return self.__performance | ['def', 'performance(self)', '->', 'Performance:', 'return', 'self.__performance'] | 918,657 |
openvinotoolkit/training_extensions | resultset.py | ResultSetEntity.has_score_metric | has_score_metric | Returns True if the resultset contains non-null performance and score value. | [
"Returns",
"True",
"if",
"the",
"resultset",
"contains",
"non-null",
"performance",
"and",
"score",
"value."
] | def has_score_metric(self) -> bool:
return not isinstance(self.performance, NullPerformance) | ['def', 'has_score_metric(self)', '->', 'bool:', 'return', 'not', 'isinstance(self.performance,', 'NullPerformance)'] | 918,660 |
openvinotoolkit/training_extensions | result_media.py | ResultMediaEntity.width | width | Returns the width of the result media. | [
"Returns",
"the",
"width",
"of",
"the",
"result",
"media."
] | def width(self) -> int:
return self.numpy.shape[1] | ['def', 'width(self)', '->', 'int:', 'return', 'self.numpy.shape[1]'] | 918,661 |
openvinotoolkit/training_extensions | result_media.py | ResultMediaEntity.height | height | Returns the height of the result media. | [
"Returns",
"the",
"height",
"of",
"the",
"result",
"media."
] | def height(self) -> int:
return self.numpy.shape[0] | ['def', 'height(self)', '->', 'int:', 'return', 'self.numpy.shape[0]'] | 918,662 |
openvinotoolkit/training_extensions | scored_label.py | ScoredLabel.name | name | Name of the label. | [
"Name",
"of",
"the",
"label."
] | def name(self) -> str:
return self.label.name | ['def', 'name(self)', '->', 'str:', 'return', 'self.label.name'] | 918,663 |
openvinotoolkit/training_extensions | scored_label.py | ScoredLabel.color | color | Color of the label. | [
"Color",
"of",
"the",
"label."
] | def color(self) -> Color:
return self.label.color | ['def', 'color(self)', '->', 'Color:', 'return', 'self.label.color'] | 918,665 |
openvinotoolkit/training_extensions | scored_label.py | ScoredLabel.hotkey | hotkey | Hotkey of the label. | [
"Hotkey",
"of",
"the",
"label."
] | def hotkey(self) -> str:
return self.label.hotkey | ['def', 'hotkey(self)', '->', 'str:', 'return', 'self.label.hotkey'] | 918,666 |
openvinotoolkit/training_extensions | scored_label.py | ScoredLabel.domain | domain | Domain of the label. | [
"Domain",
"of",
"the",
"label."
] | def domain(self) -> Domain:
return self.label.domain | ['def', 'domain(self)', '->', 'Domain:', 'return', 'self.label.domain'] | 918,667 |
openvinotoolkit/training_extensions | scored_label.py | ScoredLabel.is_empty | is_empty | Check if the label is empty. | [
"Check",
"if",
"the",
"label",
"is",
"empty."
] | def is_empty(self) -> bool:
return self.label.is_empty | ['def', 'is_empty(self)', '->', 'bool:', 'return', 'self.label.is_empty'] | 918,668 |
openvinotoolkit/training_extensions | scored_label.py | ScoredLabel.creation_date | creation_date | Creation data of the label. | [
"Creation",
"data",
"of",
"the",
"label."
] | def creation_date(self) -> datetime.datetime:
return self.label.creation_date | ['def', 'creation_date(self)', '->', 'datetime.datetime:', 'return', 'self.label.creation_date'] | 918,669 |
openvinotoolkit/training_extensions | tensor.py | TensorEntity.shape | shape | Returns the shape of the tensor. | [
"Returns",
"the",
"shape",
"of",
"the",
"tensor."
] | def shape(self) -> Tuple[int, ...]:
return self._numpy.shape | ['def', 'shape(self)', '->', 'Tuple[int,', '...]:', 'return', 'self._numpy.shape'] | 918,676 |
openvinotoolkit/training_extensions | graph_interface.py | IGraph.add_node | add_node | Add node to the graph. | [
"Add",
"node",
"to",
"the",
"graph."
] | def add_node(self, node):
raise NotImplementedError | ['def', 'add_node(self,', 'node):', 'raise', 'NotImplementedError'] | 918,677 |
openvinotoolkit/training_extensions | graph_interface.py | IGraph.add_edge | add_edge | Add an edge between node1 and node2. | [
"Add",
"an",
"edge",
"between",
"node1",
"and",
"node2."
] | def add_edge(self, node1, node2):
raise NotImplementedError | ['def', 'add_edge(self,', 'node1,', 'node2):', 'raise', 'NotImplementedError'] | 918,678 |
openvinotoolkit/training_extensions | graph_interface.py | IGraph.has_edge_between | has_edge_between | Returns whether there is an edge between `node1` and `node2`. | [
"Returns",
"whether",
"there",
"is",
"an",
"edge",
"between",
"`node1`",
"and",
"`node2`."
] | def has_edge_between(self, node1, node2):
raise NotImplementedError | ['def', 'has_edge_between(self,', 'node1,', 'node2):', 'raise', 'NotImplementedError'] | 918,679 |
openvinotoolkit/training_extensions | graph_interface.py | IGraph.neighbors | neighbors | Returns neighbors of `node`. | [
"Returns",
"neighbors",
"of",
"`node`."
] | def neighbors(self, node) -> List[dict]:
raise NotImplementedError | ['def', 'neighbors(self,', 'node)', '->', 'List[dict]:', 'raise', 'NotImplementedError'] | 918,680 |
openvinotoolkit/training_extensions | graph_interface.py | IGraph.remove_edges | remove_edges | Removes the edges between two nodes. | [
"Removes",
"the",
"edges",
"between",
"two",
"nodes."
] | def remove_edges(self, node1, node2) -> None:
raise NotImplementedError | ['def', 'remove_edges(self,', 'node1,', 'node2)', '->', 'None:', 'raise', 'NotImplementedError'] | 918,683 |
openvinotoolkit/training_extensions | graph_interface.py | IGraph.find_in_edges | find_in_edges | Returns the edges coming in to the node. | [
"Returns",
"the",
"edges",
"coming",
"in",
"to",
"the",
"node."
] | def find_in_edges(self, node) -> nx.reportviews.InMultiEdgeView:
raise NotImplementedError | ['def', 'find_in_edges(self,', 'node)', '->', 'nx.reportviews.InMultiEdgeView:', 'raise', 'NotImplementedError'] | 918,685 |
openvinotoolkit/training_extensions | graph_interface.py | IGraph.nodes | nodes | Return nodes in the graph. | [
"Return",
"nodes",
"in",
"the",
"graph."
] | def nodes(self) -> nx.reportviews.NodeView:
raise NotImplementedError | ['def', 'nodes(self)', '->', 'nx.reportviews.NodeView:', 'raise', 'NotImplementedError'] | 918,687 |
openvinotoolkit/training_extensions | ellipse.py | Ellipse.x_center | x_center | Returns the x coordinate in the center of the ellipse. | [
"Returns",
"the",
"x",
"coordinate",
"in",
"the",
"center",
"of",
"the",
"ellipse."
] | def x_center(self) -> float:
return self.x1 + self.width / 2 | ['def', 'x_center(self)', '->', 'float:', 'return', 'self.x1', '+', 'self.width', '/', '2'] | 918,690 |
openvinotoolkit/training_extensions | ellipse.py | Ellipse.y_center | y_center | Returns the y coordinate in the center of the ellipse. | [
"Returns",
"the",
"y",
"coordinate",
"in",
"the",
"center",
"of",
"the",
"ellipse."
] | def y_center(self) -> float:
return self.y1 + self.height / 2 | ['def', 'y_center(self)', '->', 'float:', 'return', 'self.y1', '+', 'self.height', '/', '2'] | 918,691 |
openvinotoolkit/training_extensions | rectangle.py | Rectangle.crop_numpy_array | crop_numpy_array | Crop the given Numpy array to the region of interest represented by this rectangle. | [
"Crop",
"the",
"given",
"Numpy",
"array",
"to",
"the",
"region",
"of",
"interest",
"represented",
"by",
"this",
"rectangle."
] | def crop_numpy_array(self, data: np.ndarray) -> np.ndarray:
x1 = max(int(round(self.x1 * data.shape[1])), 0)
x2 = max(int(round(self.x2 * data.shape[1])), 0)
y1 = max(int(round(self.y1 * data.shape[0])), 0)
y2 = max(int(round(self.y2 * data.shape[0])), 0)
return data[y1:y2, x1:x2, :] | ['def', 'crop_numpy_array(self,', 'data:', 'np.ndarray)', '->', 'np.ndarray:', 'x1', '=', 'max(int(round(self.x1', '*', 'data.shape[1])),', '0)', 'x2', '=', 'max(int(round(self.x2', '*', 'data.shape[1])),', '0)', 'y1', '=', 'max(int(round(self.y1', '*', 'data.shape[0])),', '0)', 'y2', '=', 'max(int(round(self.y2', '*',... | 918,708 |
openvinotoolkit/training_extensions | shape.py | ShapeEntity.contains_center | contains_center | Checks whether the center of the 'other' shape is located in the shape. | [
"Checks",
"whether",
"the",
"center",
"of",
"the",
"'other'",
"shape",
"is",
"located",
"in",
"the",
"shape."
] | def contains_center(self, other: 'ShapeEntity') -> bool:
raise NotImplementedError | ['def', 'contains_center(self,', 'other:', "'ShapeEntity')", '->', 'bool:', 'raise', 'NotImplementedError'] | 918,716 |
openvinotoolkit/training_extensions | shape.py | Shape.get_area | get_area | Get the area of the shape. | [
"Get",
"the",
"area",
"of",
"the",
"shape."
] | def get_area(self) -> float:
raise NotImplementedError | ['def', 'get_area(self)', '->', 'float:', 'raise', 'NotImplementedError'] | 918,719 |
openvinotoolkit/training_extensions | shape.py | Shape.intersects | intersects | Returns True, if other intersects with shape, otherwise returns False. | [
"Returns",
"True,",
"if",
"other",
"intersects",
"with",
"shape,",
"otherwise",
"returns",
"False."
] | def intersects(self, other: 'Shape') -> bool:
polygon_roi = self._as_shapely_polygon()
polygon_shape = other._as_shapely_polygon()
try:
return polygon_roi.intersects(polygon_shape)
except (PredicateError, TopologicalError) as exception:
raise GeometryException(f'The intersection between ... | ['def', 'intersects(self,', 'other:', "'Shape')", '->', 'bool:', 'polygon_roi', '=', 'self._as_shapely_polygon()', 'polygon_shape', '=', 'other._as_shapely_polygon()', 'try:', 'return', 'polygon_roi.intersects(polygon_shape)', 'except', '(PredicateError,', 'TopologicalError)', 'as', 'exception:', 'raise', "GeometryExce... | 918,720 |
openvinotoolkit/training_extensions | datetime_mapper.py | DatetimeMapper.forward | forward | Serializes datetime to str. | [
"Serializes",
"datetime",
"to",
"str."
] | def forward(instance: datetime.datetime) -> str:
return instance.strftime('%Y-%m-%dT%H:%M:%S.%f') | ['def', 'forward(instance:', 'datetime.datetime)', '->', 'str:', 'return', "instance.strftime('%Y-%m-%dT%H:%M:%S.%f')"] | 918,722 |
openvinotoolkit/training_extensions | datetime_mapper.py | DatetimeMapper.backward | backward | Deserializes datetime from str or create new one if it is None. | [
"Deserializes",
"datetime",
"from",
"str",
"or",
"create",
"new",
"one",
"if",
"it",
"is",
"None."
] | def backward(instance: Union[None, str]) -> datetime.datetime:
if isinstance(instance, str):
modification_date = datetime.datetime.strptime(instance, '%Y-%m-%dT%H:%M:%S.%f')
return modification_date.replace(tzinfo=datetime.timezone.utc)
return now() | ['def', 'backward(instance:', 'Union[None,', 'str])', '->', 'datetime.datetime:', 'if', 'isinstance(instance,', 'str):', 'modification_date', '=', 'datetime.datetime.strptime(instance,', "'%Y-%m-%dT%H:%M:%S.%f')", 'return', 'modification_date.replace(tzinfo=datetime.timezone.utc)', 'return', 'now()'] | 918,723 |
openvinotoolkit/training_extensions | id_mapper.py | IDMapper.forward | forward | Serializes ID to str. | [
"Serializes",
"ID",
"to",
"str."
] | def forward(instance: ID) -> str:
return str(instance) | ['def', 'forward(instance:', 'ID)', '->', 'str:', 'return', 'str(instance)'] | 918,724 |
openvinotoolkit/training_extensions | id_mapper.py | IDMapper.backward | backward | Deserializes ID from str. | [
"Deserializes",
"ID",
"from",
"str."
] | def backward(instance: str) -> ID:
return ID(str(instance)) | ['def', 'backward(instance:', 'str)', '->', 'ID:', 'return', 'ID(str(instance))'] | 918,725 |
openvinotoolkit/training_extensions | label_mapper.py | label_schema_to_bytes | label_schema_to_bytes | Returns json-serialized LabelSchemaEntity as bytes. | [
"Returns",
"json-serialized",
"LabelSchemaEntity",
"as",
"bytes."
] | def label_schema_to_bytes(label_schema: LabelSchemaEntity) -> bytes:
serialized_label_schema = LabelSchemaMapper.forward(label_schema)
return json.dumps(serialized_label_schema, indent=4).encode() | ['def', 'label_schema_to_bytes(label_schema:', 'LabelSchemaEntity)', '->', 'bytes:', 'serialized_label_schema', '=', 'LabelSchemaMapper.forward(label_schema)', 'return', 'json.dumps(serialized_label_schema,', 'indent=4).encode()'] | 918,726 |
openvinotoolkit/training_extensions | model_adapter.py | IDataSource.data | data | Returns the data of the source. | [
"Returns",
"the",
"data",
"of",
"the",
"source."
] | def data(self):
raise NotImplementedError | ['def', 'data(self):', 'raise', 'NotImplementedError'] | 918,727 |
openvinotoolkit/training_extensions | model_adapter.py | ModelAdapter.data_source | data_source | Returns the data source of the adapter. | [
"Returns",
"the",
"data",
"source",
"of",
"the",
"adapter."
] | def data_source(self):
return self.__data_source | ['def', 'data_source(self):', 'return', 'self.__data_source'] | 918,728 |
openvinotoolkit/training_extensions | model_adapter.py | ModelAdapter.data | data | Returns the data of the Model. | [
"Returns",
"the",
"data",
"of",
"the",
"Model."
] | def data(self):
if isinstance(self.__data_source, IDataSource):
return self.__data_source.data
if isinstance(self.__data_source, bytes):
return self.__data_source
raise ValueError('This model adapter is not properly initialized with a source of data') | ['def', 'data(self):', 'if', 'isinstance(self.__data_source,', 'IDataSource):', 'return', 'self.__data_source.data', 'if', 'isinstance(self.__data_source,', 'bytes):', 'return', 'self.__data_source', 'raise', "ValueError('This", 'model', 'adapter', 'is', 'not', 'properly', 'initialized', 'with', 'a', 'source', 'of', "d... | 918,729 |
openvinotoolkit/training_extensions | accuracy.py | precision_metrics_group | precision_metrics_group | Computes the precision per class based on a confusion matrix and returns them as ScoreMetrics in a MetricsGroup. | [
"Computes",
"the",
"precision",
"per",
"class",
"based",
"on",
"a",
"confusion",
"matrix",
"and",
"returns",
"them",
"as",
"ScoreMetrics",
"in",
"a",
"MetricsGroup."
] | def precision_metrics_group(confusion_matrix: MatrixMetric) -> MetricsGroup:
labels = confusion_matrix.row_labels
if labels is None:
if confusion_matrix.matrix_values is not None:
label_range = confusion_matrix.matrix_values.shape[0]
else:
label_range = 0
labels =... | ['def', 'precision_metrics_group(confusion_matrix:', 'MatrixMetric)', '->', 'MetricsGroup:', 'labels', '=', 'confusion_matrix.row_labels', 'if', 'labels', 'is', 'None:', 'if', 'confusion_matrix.matrix_values', 'is', 'not', 'None:', 'label_range', '=', 'confusion_matrix.matrix_values.shape[0]', 'else:', 'label_range', '... | 918,731 |
openvinotoolkit/training_extensions | accuracy.py | recall_metrics_group | recall_metrics_group | Computes the recall per class based on a confusion matrix and returns them as ScoreMetrics in a MetricsGroup. | [
"Computes",
"the",
"recall",
"per",
"class",
"based",
"on",
"a",
"confusion",
"matrix",
"and",
"returns",
"them",
"as",
"ScoreMetrics",
"in",
"a",
"MetricsGroup."
] | def recall_metrics_group(confusion_matrix: MatrixMetric) -> MetricsGroup:
labels = confusion_matrix.row_labels
if labels is None:
if confusion_matrix.matrix_values is not None:
label_range = confusion_matrix.matrix_values.shape[0]
else:
label_range = 0
labels = np... | ['def', 'recall_metrics_group(confusion_matrix:', 'MatrixMetric)', '->', 'MetricsGroup:', 'labels', '=', 'confusion_matrix.row_labels', 'if', 'labels', 'is', 'None:', 'if', 'confusion_matrix.matrix_values', 'is', 'not', 'None:', 'label_range', '=', 'confusion_matrix.matrix_values.shape[0]', 'else:', 'label_range', '=',... | 918,732 |
openvinotoolkit/training_extensions | anomaly_metrics.py | AnomalyLocalizationPerformance.global_score | global_score | Return the global (image-level) score metric. | [
"Return",
"the",
"global",
"(image-level)",
"score",
"metric."
] | def global_score(self):
return self._global_score | ['def', 'global_score(self):', 'return', 'self._global_score'] | 918,736 |
openvinotoolkit/training_extensions | anomaly_metrics.py | AnomalyLocalizationPerformance.local_score | local_score | Return the local (pixel-/bbox-level) score metric. | [
"Return",
"the",
"local",
"(pixel-/bbox-level)",
"score",
"metric."
] | def local_score(self):
return self._local_score | ['def', 'local_score(self):', 'return', 'self._local_score'] | 918,737 |
openvinotoolkit/training_extensions | anomaly_metrics.py | AnomalyLocalizationScores.get_performance | get_performance | Return the performance object for the resultset. | [
"Return",
"the",
"performance",
"object",
"for",
"the",
"resultset."
] | def get_performance(self) -> Performance:
return AnomalyLocalizationPerformance(global_score=self.global_score, local_score=self.local_score, dashboard_metrics=self.dashboard_metrics) | ['def', 'get_performance(self)', '->', 'Performance:', 'return', 'AnomalyLocalizationPerformance(global_score=self.global_score,', 'local_score=self.local_score,', 'dashboard_metrics=self.dashboard_metrics)'] | 918,738 |
openvinotoolkit/training_extensions | basic_operations.py | intersection_box | intersection_box | Calculate the intersection box of two bounding boxes. | [
"Calculate",
"the",
"intersection",
"box",
"of",
"two",
"bounding",
"boxes."
] | def intersection_box(box1: Rectangle, box2: Rectangle) -> Optional[List[float]]:
x_left = max(box1.x1, box2.x1)
y_top = max(box1.y1, box2.y1)
x_right = min(box1.x2, box2.x2)
y_bottom = min(box1.y2, box2.y2)
if x_right <= x_left or y_bottom <= y_top:
return None
return [x_left, y_top, x_r... | ['def', 'intersection_box(box1:', 'Rectangle,', 'box2:', 'Rectangle)', '->', 'Optional[List[float]]:', 'x_left', '=', 'max(box1.x1,', 'box2.x1)', 'y_top', '=', 'max(box1.y1,', 'box2.y1)', 'x_right', '=', 'min(box1.x2,', 'box2.x2)', 'y_bottom', '=', 'min(box1.y2,', 'box2.y2)', 'if', 'x_right', '<=', 'x_left', 'or', 'y_b... | 918,740 |
openvinotoolkit/training_extensions | basic_operations.py | precision_per_class | precision_per_class | Compute the precision per class based on the confusion matrix. | [
"Compute",
"the",
"precision",
"per",
"class",
"based",
"on",
"the",
"confusion",
"matrix."
] | def precision_per_class(matrix: np.ndarray) -> np.ndarray:
if not matrix.shape[0] == matrix.shape[1]:
matrix = np.delete(matrix, -1, 1)
tp_per_class = matrix.diagonal()
sum_tp_fp_per_class = matrix.sum(0)
return divide_arrays_with_possible_zeros(tp_per_class, sum_tp_fp_per_class) | ['def', 'precision_per_class(matrix:', 'np.ndarray)', '->', 'np.ndarray:', 'if', 'not', 'matrix.shape[0]', '==', 'matrix.shape[1]:', 'matrix', '=', 'np.delete(matrix,', '-1,', '1)', 'tp_per_class', '=', 'matrix.diagonal()', 'sum_tp_fp_per_class', '=', 'matrix.sum(0)', 'return', 'divide_arrays_with_possible_zeros(tp_per... | 918,742 |
openvinotoolkit/training_extensions | dice.py | DiceAverage.overall_dice | overall_dice | Returns the dice average as ScoreMetric. | [
"Returns",
"the",
"dice",
"average",
"as",
"ScoreMetric."
] | def overall_dice(self) -> ScoreMetric:
return self._overall_dice | ['def', 'overall_dice(self)', '->', 'ScoreMetric:', 'return', 'self._overall_dice'] | 918,745 |
openvinotoolkit/training_extensions | f_measure.py | FMeasure.f_measure_per_label | f_measure_per_label | Returns the f-measure per label as dictionary (Label -> ScoreMetric). | [
"Returns",
"the",
"f-measure",
"per",
"label",
"as",
"dictionary",
"(Label",
"->",
"ScoreMetric)."
] | def f_measure_per_label(self) -> Dict[LabelEntity, ScoreMetric]:
return self._f_measure_per_label | ['def', 'f_measure_per_label(self)', '->', 'Dict[LabelEntity,', 'ScoreMetric]:', 'return', 'self._f_measure_per_label'] | 918,761 |
openvinotoolkit/training_extensions | f_measure.py | FMeasure.best_confidence_threshold | best_confidence_threshold | Returns best confidence threshold as ScoreMetric if exists. | [
"Returns",
"best",
"confidence",
"threshold",
"as",
"ScoreMetric",
"if",
"exists."
] | def best_confidence_threshold(self) -> Optional[ScoreMetric]:
return self._best_confidence_threshold | ['def', 'best_confidence_threshold(self)', '->', 'Optional[ScoreMetric]:', 'return', 'self._best_confidence_threshold'] | 918,763 |
openvinotoolkit/training_extensions | f_measure.py | FMeasure.f_measure_per_nms | f_measure_per_nms | Returns the curve for f-measure per nms threshold as CurveMetric if exists. | [
"Returns",
"the",
"curve",
"for",
"f-measure",
"per",
"nms",
"threshold",
"as",
"CurveMetric",
"if",
"exists."
] | def f_measure_per_nms(self) -> Optional[CurveMetric]:
return self._f_measure_per_nms | ['def', 'f_measure_per_nms(self)', '->', 'Optional[CurveMetric]:', 'return', 'self._f_measure_per_nms'] | 918,764 |
openvinotoolkit/training_extensions | metrics_helper.py | MetricsHelper.compute_f_measure | compute_f_measure | Compute the F-Measure on a resultset given some parameters. | [
"Compute",
"the",
"F-Measure",
"on",
"a",
"resultset",
"given",
"some",
"parameters."
] | def compute_f_measure(resultset: ResultSetEntity, vary_confidence_threshold: bool=False, vary_nms_threshold: bool=False, cross_class_nms: bool=False) -> FMeasure:
return FMeasure(resultset, vary_confidence_threshold, vary_nms_threshold, cross_class_nms) | ['def', 'compute_f_measure(resultset:', 'ResultSetEntity,', 'vary_confidence_threshold:', 'bool=False,', 'vary_nms_threshold:', 'bool=False,', 'cross_class_nms:', 'bool=False)', '->', 'FMeasure:', 'return', 'FMeasure(resultset,', 'vary_confidence_threshold,', 'vary_nms_threshold,', 'cross_class_nms)'] | 918,767 |
openvinotoolkit/training_extensions | metrics_helper.py | MetricsHelper.compute_dice_averaged_over_pixels | compute_dice_averaged_over_pixels | Compute the Dice average on a resultset, averaged over the pixels. | [
"Compute",
"the",
"Dice",
"average",
"on",
"a",
"resultset,",
"averaged",
"over",
"the",
"pixels."
] | def compute_dice_averaged_over_pixels(resultset: ResultSetEntity, average: MetricAverageMethod=MetricAverageMethod.MACRO) -> DiceAverage:
return DiceAverage(resultset=resultset, average=average) | ['def', 'compute_dice_averaged_over_pixels(resultset:', 'ResultSetEntity,', 'average:', 'MetricAverageMethod=MetricAverageMethod.MACRO)', '->', 'DiceAverage:', 'return', 'DiceAverage(resultset=resultset,', 'average=average)'] | 918,768 |
openvinotoolkit/training_extensions | metrics_helper.py | MetricsHelper.compute_accuracy | compute_accuracy | Compute the Accuracy on a resultset, averaged over the different label groups. | [
"Compute",
"the",
"Accuracy",
"on",
"a",
"resultset,",
"averaged",
"over",
"the",
"different",
"label",
"groups."
] | def compute_accuracy(resultset: ResultSetEntity, average: MetricAverageMethod=MetricAverageMethod.MICRO) -> Accuracy:
return Accuracy(resultset=resultset, average=average) | ['def', 'compute_accuracy(resultset:', 'ResultSetEntity,', 'average:', 'MetricAverageMethod=MetricAverageMethod.MICRO)', '->', 'Accuracy:', 'return', 'Accuracy(resultset=resultset,', 'average=average)'] | 918,769 |
openvinotoolkit/training_extensions | metrics_helper.py | MetricsHelper.compute_anomaly_segmentation_scores | compute_anomaly_segmentation_scores | Compute the anomaly localization performance metrics on an anomaly segmentation resultset. | [
"Compute",
"the",
"anomaly",
"localization",
"performance",
"metrics",
"on",
"an",
"anomaly",
"segmentation",
"resultset."
] | def compute_anomaly_segmentation_scores(resultset: ResultSetEntity) -> AnomalySegmentationScores:
return AnomalySegmentationScores(resultset) | ['def', 'compute_anomaly_segmentation_scores(resultset:', 'ResultSetEntity)', '->', 'AnomalySegmentationScores:', 'return', 'AnomalySegmentationScores(resultset)'] | 918,770 |
openvinotoolkit/training_extensions | metrics_helper.py | MetricsHelper.compute_anomaly_detection_scores | compute_anomaly_detection_scores | Compute the anomaly localization performance metrics on an anomaly detection resultset. | [
"Compute",
"the",
"anomaly",
"localization",
"performance",
"metrics",
"on",
"an",
"anomaly",
"detection",
"resultset."
] | def compute_anomaly_detection_scores(resultset: ResultSetEntity) -> AnomalyDetectionScores:
return AnomalyDetectionScores(resultset) | ['def', 'compute_anomaly_detection_scores(resultset:', 'ResultSetEntity)', '->', 'AnomalyDetectionScores:', 'return', 'AnomalyDetectionScores(resultset)'] | 918,771 |
openvinotoolkit/training_extensions | prediction_to_annotation_converter.py | convert_bbox_to_ellipse | convert_bbox_to_ellipse | Convert bbox to ellipse. | [
"Convert",
"bbox",
"to",
"ellipse."
] | def convert_bbox_to_ellipse(x1, y1, x2, y2) -> Ellipse:
return Ellipse(x1, y1, x2, y2) | ['def', 'convert_bbox_to_ellipse(x1,', 'y1,', 'x2,', 'y2)', '->', 'Ellipse:', 'return', 'Ellipse(x1,', 'y1,', 'x2,', 'y2)'] | 918,773 |
openvinotoolkit/training_extensions | prediction_to_annotation_converter.py | create_converter | create_converter | Simple factory for converters based on type of tasks. | [
"Simple",
"factory",
"for",
"converters",
"based",
"on",
"type",
"of",
"tasks."
] | def create_converter(converter_type: Domain, labels: LabelSchemaEntity, configuration: Optional[Dict[str, Any]]=None) -> IPredictionToAnnotationConverter:
converter: IPredictionToAnnotationConverter
if converter_type == Domain.DETECTION:
converter = DetectionToAnnotationConverter(labels, configuration)
... | ['def', 'create_converter(converter_type:', 'Domain,', 'labels:', 'LabelSchemaEntity,', 'configuration:', 'Optional[Dict[str,', 'Any]]=None)', '->', 'IPredictionToAnnotationConverter:', 'converter:', 'IPredictionToAnnotationConverter', 'if', 'converter_type', '==', 'Domain.DETECTION:', 'converter', '=', 'DetectionToAnn... | 918,774 |
openvinotoolkit/training_extensions | prediction_to_annotation_converter.py | DetectionBoxToAnnotationConverter.convert_to_annotation | convert_to_annotation | Convert predictions to OTX Annotation Scene using the metadata. | [
"Convert",
"predictions",
"to",
"OTX",
"Annotation",
"Scene",
"using",
"the",
"metadata."
] | def convert_to_annotation(self, predictions: List[utils.Detection], metadata: Dict[str, Any]) -> AnnotationSceneEntity:
annotations = []
image_size = metadata['original_shape'][1::-1]
for box in predictions:
scored_label = ScoredLabel(self.labels[int(box.id)], float(box.score))
coords = np.a... | ['def', 'convert_to_annotation(self,', 'predictions:', 'List[utils.Detection],', 'metadata:', 'Dict[str,', 'Any])', '->', 'AnnotationSceneEntity:', 'annotations', '=', '[]', 'image_size', '=', "metadata['original_shape'][1::-1]", 'for', 'box', 'in', 'predictions:', 'scored_label', '=', 'ScoredLabel(self.labels[int(box.... | 918,777 |
openvinotoolkit/training_extensions | demo.py | get_inferencer_class | get_inferencer_class | Return class for inference of models. | [
"Return",
"class",
"for",
"inference",
"of",
"models."
] | def get_inferencer_class(type_inference, models):
if len(models) > 1:
type_inference = 'chain'
print('You started the task chain pipeline with the provided models in the order in which they were specified')
return EXECUTORS[type_inference] | ['def', 'get_inferencer_class(type_inference,', 'models):', 'if', 'len(models)', '>', '1:', 'type_inference', '=', "'chain'", "print('You", 'started', 'the', 'task', 'chain', 'pipeline', 'with', 'the', 'provided', 'models', 'in', 'the', 'order', 'in', 'which', 'they', 'were', "specified')", 'return', 'EXECUTORS[type_in... | 918,787 |
openvinotoolkit/training_extensions | model_container.py | ModelContainer.setup_tiler | setup_tiler | Setup tiler for model. | [
"Setup",
"tiler",
"for",
"model."
] | def setup_tiler(self, model_dir, device) -> Optional[Union[DetectionTiler, InstanceSegmentationTiler]]:
if not self.parameters.get('tiling_parameters') or not self.parameters['tiling_parameters']['enable_tiling']:
return None
classifier = None
if self.parameters['tiling_parameters'].get('enable_tile... | ['def', 'setup_tiler(self,', 'model_dir,', 'device)', '->', 'Optional[Union[DetectionTiler,', 'InstanceSegmentationTiler]]:', 'if', 'not', "self.parameters.get('tiling_parameters')", 'or', 'not', "self.parameters['tiling_parameters']['enable_tiling']:", 'return', 'None', 'classifier', '=', 'None', 'if', "self.parameter... | 918,788 |
openvinotoolkit/training_extensions | model_container.py | ModelContainer.infer | infer | Infer with original image. | [
"Infer",
"with",
"original",
"image."
] | def infer(self, frame):
predictions = self.core_model(frame)
frame_meta = {'original_shape': frame.shape}
if self._task_type == TaskType.DETECTION:
predictions = detection2array(predictions.objects)
return (predictions, frame_meta) | ['def', 'infer(self,', 'frame):', 'predictions', '=', 'self.core_model(frame)', 'frame_meta', '=', "{'original_shape':", 'frame.shape}', 'if', 'self._task_type', '==', 'TaskType.DETECTION:', 'predictions', '=', 'detection2array(predictions.objects)', 'return', '(predictions,', 'frame_meta)'] | 918,789 |
openvinotoolkit/training_extensions | model_container.py | ModelContainer.infer_tile | infer_tile | Infer by patching full image to tiles. | [
"Infer",
"by",
"patching",
"full",
"image",
"to",
"tiles."
] | def infer_tile(self, frame):
detections = self.tiler(frame)
return (detections, {'original_shape': frame.shape}) | ['def', 'infer_tile(self,', 'frame):', 'detections', '=', 'self.tiler(frame)', 'return', '(detections,', "{'original_shape':", 'frame.shape})'] | 918,790 |
openvinotoolkit/training_extensions | utils.py | get_model_path | get_model_path | Get path to model. | [
"Get",
"path",
"to",
"model."
] | def get_model_path(path: Optional[Path]) -> Path:
model_path = path
if model_path is None:
model_path = Path(__file__).parent / 'model.xml'
if not model_path.exists():
raise IOError('The path to the model was not found.')
return model_path | ['def', 'get_model_path(path:', 'Optional[Path])', '->', 'Path:', 'model_path', '=', 'path', 'if', 'model_path', 'is', 'None:', 'model_path', '=', 'Path(__file__).parent', '/', "'model.xml'", 'if', 'not', 'model_path.exists():', 'raise', "IOError('The", 'path', 'to', 'the', 'model', 'was', 'not', "found.')", 'return', ... | 918,791 |
openvinotoolkit/training_extensions | utils.py | get_parameters | get_parameters | Get hyper parameters to creating model. | [
"Get",
"hyper",
"parameters",
"to",
"creating",
"model."
] | def get_parameters(path: Optional[Path]) -> dict:
parameters_path = path
if parameters_path is None:
parameters_path = Path(__file__).parent / 'config.json'
if not parameters_path.exists():
raise IOError('The path to the config was not found.')
with open(parameters_path, 'r', encoding='u... | ['def', 'get_parameters(path:', 'Optional[Path])', '->', 'dict:', 'parameters_path', '=', 'path', 'if', 'parameters_path', 'is', 'None:', 'parameters_path', '=', 'Path(__file__).parent', '/', "'config.json'", 'if', 'not', 'parameters_path.exists():', 'raise', "IOError('The", 'path', 'to', 'the', 'config', 'was', 'not',... | 918,792 |
openvinotoolkit/training_extensions | utils.py | create_output_converter | create_output_converter | Create annotation converter according to kind of task. | [
"Create",
"annotation",
"converter",
"according",
"to",
"kind",
"of",
"task."
] | def create_output_converter(task_type: TaskType, labels: LabelSchemaEntity, model_params: Dict[Any, Any]):
converter_type = task_type_to_label_domain(task_type)
return create_converter(converter_type, labels, model_params) | ['def', 'create_output_converter(task_type:', 'TaskType,', 'labels:', 'LabelSchemaEntity,', 'model_params:', 'Dict[Any,', 'Any]):', 'converter_type', '=', 'task_type_to_label_domain(task_type)', 'return', 'create_converter(converter_type,', 'labels,', 'model_params)'] | 918,793 |
openvinotoolkit/training_extensions | utils.py | create_visualizer | create_visualizer | Create visualizer according to kind of task. | [
"Create",
"visualizer",
"according",
"to",
"kind",
"of",
"task."
] | def create_visualizer(_task_type: TaskType, no_show: bool=False, output: Optional[str]=None):
return Visualizer(window_name='Result', no_show=no_show, output=output) | ['def', 'create_visualizer(_task_type:', 'TaskType,', 'no_show:', 'bool=False,', 'output:', 'Optional[str]=None):', 'return', "Visualizer(window_name='Result',", 'no_show=no_show,', 'output=output)'] | 918,794 |
openvinotoolkit/training_extensions | asynchronous.py | AsyncExecutor.run | run | Async inference for input stream (image, video stream, camera). | [
"Async",
"inference",
"for",
"input",
"stream",
"(image,",
"video",
"stream,",
"camera)."
] | def run(self, input_stream: Union[int, str], loop: bool=False) -> None:
streamer = get_streamer(input_stream, loop)
next_frame_id = 0
next_frame_id_to_show = 0
stop_visualization = False
saved_frames = []
for frame in streamer:
results = self.async_pipeline.get_result(next_frame_id_to_sh... | ['def', 'run(self,', 'input_stream:', 'Union[int,', 'str],', 'loop:', 'bool=False)', '->', 'None:', 'streamer', '=', 'get_streamer(input_stream,', 'loop)', 'next_frame_id', '=', '0', 'next_frame_id_to_show', '=', '0', 'stop_visualization', '=', 'False', 'saved_frames', '=', '[]', 'for', 'frame', 'in', 'streamer:', 'res... | 918,795 |
openvinotoolkit/training_extensions | asynchronous.py | AsyncExecutor.render_result | render_result | Render for results of inference. | [
"Render",
"for",
"results",
"of",
"inference."
] | def render_result(self, results: Tuple[Any, dict]) -> np.ndarray:
(predictions, frame_meta) = results
if isinstance(self.converter, DetectionToAnnotationConverter):
predictions = np.array([[pred.id, pred.score, *[pred.xmin, pred.ymin, pred.xmax, pred.ymax]] for pred in predictions.objects])
pred... | ['def', 'render_result(self,', 'results:', 'Tuple[Any,', 'dict])', '->', 'np.ndarray:', '(predictions,', 'frame_meta)', '=', 'results', 'if', 'isinstance(self.converter,', 'DetectionToAnnotationConverter):', 'predictions', '=', 'np.array([[pred.id,', 'pred.score,', '*[pred.xmin,', 'pred.ymin,', 'pred.xmax,', 'pred.ymax... | 918,796 |
openvinotoolkit/training_extensions | synchronous.py | SyncExecutor.run | run | Run demo using input stream (image, video stream, camera). | [
"Run",
"demo",
"using",
"input",
"stream",
"(image,",
"video",
"stream,",
"camera)."
] | def run(self, input_stream: Union[int, str], loop: bool=False) -> None:
streamer = get_streamer(input_stream, loop)
saved_frames = []
for frame in streamer:
start_time = time.perf_counter()
(predictions, frame_meta) = self.model(frame)
annotation_scene = self.converter.convert_to_ann... | ['def', 'run(self,', 'input_stream:', 'Union[int,', 'str],', 'loop:', 'bool=False)', '->', 'None:', 'streamer', '=', 'get_streamer(input_stream,', 'loop)', 'saved_frames', '=', '[]', 'for', 'frame', 'in', 'streamer:', 'start_time', '=', 'time.perf_counter()', '(predictions,', 'frame_meta)', '=', 'self.model(frame)', 'a... | 918,797 |
openvinotoolkit/training_extensions | sync_pipeline.py | ChainExecutor.single_run | single_run | Inference for single image. | [
"Inference",
"for",
"single",
"image."
] | def single_run(self, input_image: np.ndarray) -> AnnotationSceneEntity:
current_objects = [(input_image, Annotation(Rectangle(0, 0, 1, 1), labels=[]))]
result_scene = AnnotationSceneEntity([], AnnotationSceneKind.PREDICTION)
for (index, model) in enumerate(self.models):
new_objects = []
for ... | ['def', 'single_run(self,', 'input_image:', 'np.ndarray)', '->', 'AnnotationSceneEntity:', 'current_objects', '=', '[(input_image,', 'Annotation(Rectangle(0,', '0,', '1,', '1),', 'labels=[]))]', 'result_scene', '=', 'AnnotationSceneEntity([],', 'AnnotationSceneKind.PREDICTION)', 'for', '(index,', 'model)', 'in', 'enume... | 918,798 |
openvinotoolkit/training_extensions | sync_pipeline.py | ChainExecutor.crop | crop | Crop operation between chain stages. | [
"Crop",
"operation",
"between",
"chain",
"stages."
] | def crop(item: np.ndarray, parent_annotation: Annotation, item_annotation: Annotation) -> Tuple[np.ndarray, Annotation]:
new_item = ShapeFactory.shape_as_rectangle(item_annotation.shape).crop_numpy_array(item)
item_annotation.shape = item_annotation.shape.normalize_wrt_roi_shape(ShapeFactory.shape_as_rectangle(... | ['def', 'crop(item:', 'np.ndarray,', 'parent_annotation:', 'Annotation,', 'item_annotation:', 'Annotation)', '->', 'Tuple[np.ndarray,', 'Annotation]:', 'new_item', '=', 'ShapeFactory.shape_as_rectangle(item_annotation.shape).crop_numpy_array(item)', 'item_annotation.shape', '=', 'item_annotation.shape.normalize_wrt_roi... | 918,799 |
openvinotoolkit/training_extensions | inference.py | IInferencer.predict | predict | This method performs a prediction. | [
"This",
"method",
"performs",
"a",
"prediction."
] | def predict(self, image: np.ndarray) -> Union[AnnotationSceneEntity, Tuple[Any, ...]]:
raise NotImplementedError | ['def', 'predict(self,', 'image:', 'np.ndarray)', '->', 'Union[AnnotationSceneEntity,', 'Tuple[Any,', '...]]:', 'raise', 'NotImplementedError'] | 918,801 |
openvinotoolkit/training_extensions | streamer.py | get_streamer | get_streamer | Get streamer object based on the file path or camera device index provided. | [
"Get",
"streamer",
"object",
"based",
"on",
"the",
"file",
"path",
"or",
"camera",
"device",
"index",
"provided."
] | def get_streamer(input_stream: Union[int, str]=0, loop: bool=False, threaded: bool=False) -> BaseStreamer:
errors = []
streamer: BaseStreamer
for reader in (ImageStreamer, DirStreamer, VideoStreamer):
try:
streamer = reader(input_stream, loop)
if threaded:
str... | ['def', 'get_streamer(input_stream:', 'Union[int,', 'str]=0,', 'loop:', 'bool=False,', 'threaded:', 'bool=False)', '->', 'BaseStreamer:', 'errors', '=', '[]', 'streamer:', 'BaseStreamer', 'for', 'reader', 'in', '(ImageStreamer,', 'DirStreamer,', 'VideoStreamer):', 'try:', 'streamer', '=', 'reader(input_stream,', 'loop)... | 918,802 |
openvinotoolkit/training_extensions | streamer.py | BaseStreamer.fps | fps | Returns a frequency of getting images from source. | [
"Returns",
"a",
"frequency",
"of",
"getting",
"images",
"from",
"source."
] | def fps(self):
raise NotImplementedError | ['def', 'fps(self):', 'raise', 'NotImplementedError'] | 918,804 |
openvinotoolkit/training_extensions | anomaly_visualizer.py | AnomalyVisualizer.draw | draw | Draw annotations on the image. | [
"Draw",
"annotations",
"on",
"the",
"image."
] | def draw(self, image: np.ndarray, annotation: AnnotationSceneEntity, meta: dict) -> np.ndarray:
heat_mask = self.to_heat_mask(1 - meta['anomaly_map'])
alpha = cv2.getTrackbarPos(self.trackbar_name, self.window_name) / 100.0
image = (1 - alpha) * image + alpha * heat_mask
image = cv2.cvtColor(image.astyp... | ['def', 'draw(self,', 'image:', 'np.ndarray,', 'annotation:', 'AnnotationSceneEntity,', 'meta:', 'dict)', '->', 'np.ndarray:', 'heat_mask', '=', 'self.to_heat_mask(1', '-', "meta['anomaly_map'])", 'alpha', '=', 'cv2.getTrackbarPos(self.trackbar_name,', 'self.window_name)', '/', '100.0', 'image', '=', '(1', '-', 'alpha)... | 918,812 |
openvinotoolkit/training_extensions | visualizer.py | IVisualizer.is_quit | is_quit | Check if user wishes to quit. | [
"Check",
"if",
"user",
"wishes",
"to",
"quit."
] | def is_quit(self) -> bool:
raise NotImplementedError | ['def', 'is_quit(self)', '->', 'bool:', 'raise', 'NotImplementedError'] | 918,814 |
openvinotoolkit/training_extensions | visualizer.py | IVisualizer.video_delay | video_delay | Check if video frames were inferenced faster than the original video FPS and delay visualizer if so. | [
"Check",
"if",
"video",
"frames",
"were",
"inferenced",
"faster",
"than",
"the",
"original",
"video",
"FPS",
"and",
"delay",
"visualizer",
"if",
"so."
] | def video_delay(self, elapsed_time: float, streamer: BaseStreamer) -> None:
raise NotImplementedError | ['def', 'video_delay(self,', 'elapsed_time:', 'float,', 'streamer:', 'BaseStreamer)', '->', 'None:', 'raise', 'NotImplementedError'] | 918,815 |
openvinotoolkit/training_extensions | visualizer.py | Visualizer.is_quit | is_quit | Check user wish to quit. | [
"Check",
"user",
"wish",
"to",
"quit."
] | def is_quit(self) -> bool:
if self.no_show:
return False
return ord('q') == cv2.waitKey(self.delay) | ['def', 'is_quit(self)', '->', 'bool:', 'if', 'self.no_show:', 'return', 'False', 'return', "ord('q')", '==', 'cv2.waitKey(self.delay)'] | 918,817 |
openvinotoolkit/training_extensions | time_monitor_callback.py | TimeMonitorCallback.on_train_batch_begin | on_train_batch_begin | Set the value of current step and start the timer. | [
"Set",
"the",
"value",
"of",
"current",
"step",
"and",
"start",
"the",
"timer."
] | def on_train_batch_begin(self, batch, logs=None):
self.current_step += 1
self.start_step_time = time.time() | ['def', 'on_train_batch_begin(self,', 'batch,', 'logs=None):', 'self.current_step', '+=', '1', 'self.start_step_time', '=', 'time.time()'] | 918,819 |
openvinotoolkit/training_extensions | time_monitor_callback.py | TimeMonitorCallback.on_test_batch_end | on_test_batch_end | Compute average time taken to complete a step based on a running average of `step_history` steps. | [
"Compute",
"average",
"time",
"taken",
"to",
"complete",
"a",
"step",
"based",
"on",
"a",
"running",
"average",
"of",
"`step_history`",
"steps."
] | def on_test_batch_end(self, batch, logs):
self.__calculate_average_step() | ['def', 'on_test_batch_end(self,', 'batch,', 'logs):', 'self.__calculate_average_step()'] | 918,823 |
openvinotoolkit/training_extensions | time_monitor_callback.py | TimeMonitorCallback.on_train_end | on_train_end | Handles early stopping when the total_steps is greater than the current_step. | [
"Handles",
"early",
"stopping",
"when",
"the",
"total_steps",
"is",
"greater",
"than",
"the",
"current_step."
] | def on_train_end(self, logs=None):
self.current_step = self.total_steps - self.test_steps
self.current_epoch = self.total_epochs
self.is_training = False | ['def', 'on_train_end(self,', 'logs=None):', 'self.current_step', '=', 'self.total_steps', '-', 'self.test_steps', 'self.current_epoch', '=', 'self.total_epochs', 'self.is_training', '=', 'False'] | 918,825 |
openvinotoolkit/training_extensions | time_monitor_callback.py | TimeMonitorCallback.on_epoch_begin | on_epoch_begin | Set the number of current epoch and start the timer. | [
"Set",
"the",
"number",
"of",
"current",
"epoch",
"and",
"start",
"the",
"timer."
] | def on_epoch_begin(self, epoch, logs=None):
self.current_epoch = epoch + 1
self.start_epoch_time = time.time() | ['def', 'on_epoch_begin(self,', 'epoch,', 'logs=None):', 'self.current_epoch', '=', 'epoch', '+', '1', 'self.start_epoch_time', '=', 'time.time()'] | 918,826 |
openvinotoolkit/training_extensions | export_interface.py | IExportTask.export | export | This method defines the interface for export. | [
"This",
"method",
"defines",
"the",
"interface",
"for",
"export."
] | def export(self, export_type: ExportType, output_model: ModelEntity, precision: ModelPrecision, dump_features: bool):
raise NotImplementedError | ['def', 'export(self,', 'export_type:', 'ExportType,', 'output_model:', 'ModelEntity,', 'precision:', 'ModelPrecision,', 'dump_features:', 'bool):', 'raise', 'NotImplementedError'] | 918,832 |
openvinotoolkit/training_extensions | optimization_interface.py | IOptimizationTask.optimize | optimize | This method defines the interface for optimization. | [
"This",
"method",
"defines",
"the",
"interface",
"for",
"optimization."
] | def optimize(self, optimization_type: OptimizationType, dataset: DatasetEntity, output_model: ModelEntity, optimization_parameters: Optional[OptimizationParameters]):
raise NotImplementedError | ['def', 'optimize(self,', 'optimization_type:', 'OptimizationType,', 'dataset:', 'DatasetEntity,', 'output_model:', 'ModelEntity,', 'optimization_parameters:', 'Optional[OptimizationParameters]):', 'raise', 'NotImplementedError'] | 918,835 |
openvinotoolkit/training_extensions | argument_checks.py | get_parameter_repr | get_parameter_repr | Function to get parameter representation. | [
"Function",
"to",
"get",
"parameter",
"representation."
] | def get_parameter_repr(parameter) -> str:
try:
parameter_str = repr(parameter)
except Exception:
parameter_str = '<unable to get parameter repr>'
return parameter_str | ['def', 'get_parameter_repr(parameter)', '->', 'str:', 'try:', 'parameter_str', '=', 'repr(parameter)', 'except', 'Exception:', 'parameter_str', '=', "'<unable", 'to', 'get', 'parameter', "repr>'", 'return', 'parameter_str'] | 918,842 |
openvinotoolkit/training_extensions | argument_checks.py | check_nested_classes_parameters | check_nested_classes_parameters | Function to check type of parameters with nested elements. | [
"Function",
"to",
"check",
"type",
"of",
"parameters",
"with",
"nested",
"elements."
] | def check_nested_classes_parameters(parameter, parameter_name, origin_class, nested_elements_class):
raise_value_error_if_parameter_has_unexpected_type(parameter=parameter, parameter_name=parameter_name, expected_type=origin_class)
if origin_class == dict:
if len(nested_elements_class) != 2:
... | ['def', 'check_nested_classes_parameters(parameter,', 'parameter_name,', 'origin_class,', 'nested_elements_class):', 'raise_value_error_if_parameter_has_unexpected_type(parameter=parameter,', 'parameter_name=parameter_name,', 'expected_type=origin_class)', 'if', 'origin_class', '==', 'dict:', 'if', 'len(nested_elements... | 918,846 |
openvinotoolkit/training_extensions | argument_checks.py | check_parameter_type | check_parameter_type | Function extracts nested expected types and raises ValueError exception if parameter has unexpected type. | [
"Function",
"extracts",
"nested",
"expected",
"types",
"and",
"raises",
"ValueError",
"exception",
"if",
"parameter",
"has",
"unexpected",
"type."
] | def check_parameter_type(parameter, parameter_name, expected_type):
if expected_type in [typing.Any, inspect._empty]:
return
if not isinstance(expected_type, typing._GenericAlias):
raise_value_error_if_parameter_has_unexpected_type(parameter=parameter, parameter_name=parameter_name, expected_typ... | ['def', 'check_parameter_type(parameter,', 'parameter_name,', 'expected_type):', 'if', 'expected_type', 'in', '[typing.Any,', 'inspect._empty]:', 'return', 'if', 'not', 'isinstance(expected_type,', 'typing._GenericAlias):', 'raise_value_error_if_parameter_has_unexpected_type(parameter=parameter,', 'parameter_name=param... | 918,847 |
openvinotoolkit/training_extensions | argument_checks.py | check_input_parameters_type | check_input_parameters_type | Decorator to check input parameters type. | [
"Decorator",
"to",
"check",
"input",
"parameters",
"type."
] | def check_input_parameters_type(custom_checks: typing.Optional[dict]=None):
if custom_checks is None:
custom_checks = {}
def _check_input_parameters_type(function):
@wraps(function)
def validate(*args, **kwargs):
signature = inspect.signature(function)
expected_... | ['def', 'check_input_parameters_type(custom_checks:', 'typing.Optional[dict]=None):', 'if', 'custom_checks', 'is', 'None:', 'custom_checks', '=', '{}', 'def', '_check_input_parameters_type(function):', '@wraps(function)', 'def', 'validate(*args,', '**kwargs):', 'signature', '=', 'inspect.signature(function)', 'expected... | 918,848 |
openvinotoolkit/training_extensions | argument_checks.py | check_file_extension | check_file_extension | Function raises ValueError exception if file has unexpected extension. | [
"Function",
"raises",
"ValueError",
"exception",
"if",
"file",
"has",
"unexpected",
"extension."
] | def check_file_extension(file_path: str, file_path_name: str, expected_extensions: list):
file_extension = splitext(file_path)[1].lower()
if file_extension not in expected_extensions:
raise ValueError(f'Unexpected extension of {file_path_name} file. expected: {expected_extensions} actual: {file_extensio... | ['def', 'check_file_extension(file_path:', 'str,', 'file_path_name:', 'str,', 'expected_extensions:', 'list):', 'file_extension', '=', 'splitext(file_path)[1].lower()', 'if', 'file_extension', 'not', 'in', 'expected_extensions:', 'raise', "ValueError(f'Unexpected", 'extension', 'of', '{file_path_name}', 'file.', 'expec... | 918,849 |
openvinotoolkit/training_extensions | argument_checks.py | check_that_null_character_absents_in_string | check_that_null_character_absents_in_string | Function raises ValueError exception if null character: '\0' is specified in path to file. | [
"Function",
"raises",
"ValueError",
"exception",
"if",
"null",
"character:",
"'\\0'",
"is",
"specified",
"in",
"path",
"to",
"file."
] | def check_that_null_character_absents_in_string(parameter: str, parameter_name: str):
if '\x00' in parameter:
raise ValueError(f'null char \\0 is specified in {parameter_name}: {parameter}') | ['def', 'check_that_null_character_absents_in_string(parameter:', 'str,', 'parameter_name:', 'str):', 'if', "'\\x00'", 'in', 'parameter:', 'raise', "ValueError(f'null", 'char', '\\\\0', 'is', 'specified', 'in', '{parameter_name}:', "{parameter}')"] | 918,850 |
openvinotoolkit/training_extensions | argument_checks.py | check_that_file_exists | check_that_file_exists | Function raises ValueError exception if file not exists. | [
"Function",
"raises",
"ValueError",
"exception",
"if",
"file",
"not",
"exists."
] | def check_that_file_exists(file_path: str, file_path_name: str):
if not exists(file_path):
raise ValueError(f"File {file_path} specified in '{file_path_name}' parameter not exists") | ['def', 'check_that_file_exists(file_path:', 'str,', 'file_path_name:', 'str):', 'if', 'not', 'exists(file_path):', 'raise', 'ValueError(f"File', '{file_path}', 'specified', 'in', "'{file_path_name}'", 'parameter', 'not', 'exists")'] | 918,851 |
openvinotoolkit/training_extensions | argument_checks.py | check_that_all_characters_printable | check_that_all_characters_printable | Function raises ValueError if one of string-parameter characters is not printable. | [
"Function",
"raises",
"ValueError",
"if",
"one",
"of",
"string-parameter",
"characters",
"is",
"not",
"printable."
] | def check_that_all_characters_printable(parameter, parameter_name, allow_crlf=False):
if not allow_crlf:
all_characters_printable = all((c.isprintable() for c in parameter))
else:
all_characters_printable = all((c.isprintable() or c == '\n' or c == '\r' for c in parameter))
if not all_charac... | ['def', 'check_that_all_characters_printable(parameter,', 'parameter_name,', 'allow_crlf=False):', 'if', 'not', 'allow_crlf:', 'all_characters_printable', '=', 'all((c.isprintable()', 'for', 'c', 'in', 'parameter))', 'else:', 'all_characters_printable', '=', 'all((c.isprintable()', 'or', 'c', '==', "'\\n'", 'or', 'c', ... | 918,853 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.