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 | segment_anything.py | SegmentAnything.load_checkpoint | load_checkpoint | Load checkpoint for SAM. | [
"Load",
"checkpoint",
"for",
"SAM."
] | def load_checkpoint(self, state_dict: Optional[OrderedDict]=None, revise_keys: List=[('^image_encoder.', 'image_encoder.backbone.')]) -> None:
def replace_state_dict_keys(state_dict, revise_keys):
for (p, r) in revise_keys:
state_dict = OrderedDict({re.sub(p, r, k) if re.search(p, k) and (not r... | ['def', 'load_checkpoint(self,', 'state_dict:', 'Optional[OrderedDict]=None,', 'revise_keys:', "List=[('^image_encoder.',", "'image_encoder.backbone.')])", '->', 'None:', 'def', 'replace_state_dict_keys(state_dict,', 'revise_keys):', 'for', '(p,', 'r)', 'in', 'revise_keys:', 'state_dict', '=', 'OrderedDict({re.sub(p,',... | 918,363 |
openvinotoolkit/training_extensions | segment_anything.py | SegmentAnything.select_masks | select_masks | Selects the best mask from a batch of masks. | [
"Selects",
"the",
"best",
"mask",
"from",
"a",
"batch",
"of",
"masks."
] | def select_masks(self, masks: Tensor, iou_preds: Tensor, num_points: int) -> Tuple[Tensor, Tensor]:
score_reweight = torch.tensor([[1000] + [0] * (self.mask_decoder.num_mask_tokens - 1)]).to(iou_preds.device)
score = iou_preds + (num_points - 2.5) * score_reweight
best_idx = torch.argmax(score, dim=1)
m... | ['def', 'select_masks(self,', 'masks:', 'Tensor,', 'iou_preds:', 'Tensor,', 'num_points:', 'int)', '->', 'Tuple[Tensor,', 'Tensor]:', 'score_reweight', '=', 'torch.tensor([[1000]', '+', '[0]', '*', '(self.mask_decoder.num_mask_tokens', '-', '1)]).to(iou_preds.device)', 'score', '=', 'iou_preds', '+', '(num_points', '-'... | 918,366 |
openvinotoolkit/training_extensions | segment_anything.py | SegmentAnything.resize_longest_image_size | resize_longest_image_size | Resizes the longest side of the image to the given size. | [
"Resizes",
"the",
"longest",
"side",
"of",
"the",
"image",
"to",
"the",
"given",
"size."
] | def resize_longest_image_size(self, input_image_size: Tensor, longest_side: int) -> Tensor:
input_image_size = input_image_size.to(torch.float32)
scale = longest_side / torch.max(input_image_size)
transformed_size = scale * input_image_size
transformed_size = torch.floor(transformed_size + 0.5).to(torch... | ['def', 'resize_longest_image_size(self,', 'input_image_size:', 'Tensor,', 'longest_side:', 'int)', '->', 'Tensor:', 'input_image_size', '=', 'input_image_size.to(torch.float32)', 'scale', '=', 'longest_side', '/', 'torch.max(input_image_size)', 'transformed_size', '=', 'scale', '*', 'input_image_size', 'transformed_si... | 918,368 |
openvinotoolkit/training_extensions | segment_anything.py | SegmentAnything.forward_train | forward_train | Forward method for SAM training/validation/prediction. | [
"Forward",
"method",
"for",
"SAM",
"training/validation/prediction."
] | def forward_train(self, images: Tensor, bboxes: List[Tensor], points: Optional[Tuple[Tensor, Tensor]]=None, masks: Optional[Tensor]=None) -> Tuple[List[Tensor], List[Tensor]]:
image_embeddings = self.image_encoder(images)
pred_masks = []
ious = []
for (embedding, bbox) in zip(image_embeddings, bboxes):
... | ['def', 'forward_train(self,', 'images:', 'Tensor,', 'bboxes:', 'List[Tensor],', 'points:', 'Optional[Tuple[Tensor,', 'Tensor]]=None,', 'masks:', 'Optional[Tensor]=None)', '->', 'Tuple[List[Tensor],', 'List[Tensor]]:', 'image_embeddings', '=', 'self.image_encoder(images)', 'pred_masks', '=', '[]', 'ious', '=', '[]', 'f... | 918,369 |
openvinotoolkit/training_extensions | segment_anything.py | SegmentAnything.training_epoch_end | training_epoch_end | Training epoch end for SAM. | [
"Training",
"epoch",
"end",
"for",
"SAM."
] | def training_epoch_end(self, outputs) -> None:
for v in self.train_metrics.values():
v.reset() | ['def', 'training_epoch_end(self,', 'outputs)', '->', 'None:', 'for', 'v', 'in', 'self.train_metrics.values():', 'v.reset()'] | 918,371 |
openvinotoolkit/training_extensions | segment_anything.py | SegmentAnything.predict_step | predict_step | Predict step of SAM. | [
"Predict",
"step",
"of",
"SAM."
] | def predict_step(self, batch, batch_idx) -> Dict[str, Tensor]:
images = batch['images']
bboxes = batch['bboxes']
points = batch['points']
(pred_masks, iou_predictions) = self.forward_train(images, bboxes, points)
masks: List[Tensor] = []
for (i, pred_mask) in enumerate(pred_masks):
mask ... | ['def', 'predict_step(self,', 'batch,', 'batch_idx)', '->', 'Dict[str,', 'Tensor]:', 'images', '=', "batch['images']", 'bboxes', '=', "batch['bboxes']", 'points', '=', "batch['points']", '(pred_masks,', 'iou_predictions)', '=', 'self.forward_train(images,', 'bboxes,', 'points)', 'masks:', 'List[Tensor]', '=', '[]', 'fo... | 918,374 |
openvinotoolkit/training_extensions | segment_anything.py | SegmentAnything.postprocess_masks | postprocess_masks | Remove padding and upscale masks to the original image size. | [
"Remove",
"padding",
"and",
"upscale",
"masks",
"to",
"the",
"original",
"image",
"size."
] | def postprocess_masks(self, masks: Tensor, input_size: Tuple[int, int], padding: Tuple[int, ...], original_size: Tuple[int, int]) -> Tensor:
masks = F.interpolate(masks, input_size, mode='bilinear', align_corners=False)
masks = masks[..., :input_size[0] - padding[3], :input_size[1] - padding[2]]
masks = F.i... | ['def', 'postprocess_masks(self,', 'masks:', 'Tensor,', 'input_size:', 'Tuple[int,', 'int],', 'padding:', 'Tuple[int,', '...],', 'original_size:', 'Tuple[int,', 'int])', '->', 'Tensor:', 'masks', '=', 'F.interpolate(masks,', 'input_size,', "mode='bilinear',", 'align_corners=False)', 'masks', '=', 'masks[...,', ':input_... | 918,375 |
openvinotoolkit/training_extensions | segment_anything.py | SegmentAnything.calculate_dice_loss | calculate_dice_loss | Compute the DICE loss, similar to generalized IOU for masks. | [
"Compute",
"the",
"DICE",
"loss,",
"similar",
"to",
"generalized",
"IOU",
"for",
"masks."
] | def calculate_dice_loss(self, inputs: Tensor, targets: Tensor, num_masks: int) -> Tensor:
numerator = 2 * (inputs * targets).sum(-1)
denominator = inputs.sum(-1) + targets.sum(-1)
loss = 1 - (numerator + 1) / (denominator + 1)
return loss.sum() / num_masks | ['def', 'calculate_dice_loss(self,', 'inputs:', 'Tensor,', 'targets:', 'Tensor,', 'num_masks:', 'int)', '->', 'Tensor:', 'numerator', '=', '2', '*', '(inputs', '*', 'targets).sum(-1)', 'denominator', '=', 'inputs.sum(-1)', '+', 'targets.sum(-1)', 'loss', '=', '1', '-', '(numerator', '+', '1)', '/', '(denominator', '+',... | 918,377 |
openvinotoolkit/training_extensions | segment_anything.py | SegmentAnything.calculate_iou | calculate_iou | Calculate the intersection over union (IOU) between the predicted mask and the ground truth mask. | [
"Calculate",
"the",
"intersection",
"over",
"union",
"(IOU)",
"between",
"the",
"predicted",
"mask",
"and",
"the",
"ground",
"truth",
"mask."
] | def calculate_iou(self, inputs: Tensor, targets: Tensor, epsilon: float=1e-07) -> Tensor:
pred_mask = (inputs >= 0.5).float()
intersection = torch.sum(torch.mul(pred_mask, targets), dim=1)
union = torch.sum(pred_mask, dim=1) + torch.sum(targets, dim=1) - intersection
iou = intersection / (union + epsilo... | ['def', 'calculate_iou(self,', 'inputs:', 'Tensor,', 'targets:', 'Tensor,', 'epsilon:', 'float=1e-07)', '->', 'Tensor:', 'pred_mask', '=', '(inputs', '>=', '0.5).float()', 'intersection', '=', 'torch.sum(torch.mul(pred_mask,', 'targets),', 'dim=1)', 'union', '=', 'torch.sum(pred_mask,', 'dim=1)', '+', 'torch.sum(target... | 918,379 |
openvinotoolkit/training_extensions | openvino.py | OpenVINOVisualPromptingInferencer.post_process | post_process | Post-process function of OpenVINO Visual Prompting Inferencer. | [
"Post-process",
"function",
"of",
"OpenVINO",
"Visual",
"Prompting",
"Inferencer."
] | def post_process(self, prediction: Dict[str, np.ndarray], metadata: Dict[str, Any]) -> Tuple[List[Annotation], Any, Any]:
(hard_prediction, soft_prediction) = self.model['decoder'].postprocess(prediction, metadata)
annotation = self.converter.convert_to_annotation(hard_prediction, metadata)
return (annotati... | ['def', 'post_process(self,', 'prediction:', 'Dict[str,', 'np.ndarray],', 'metadata:', 'Dict[str,', 'Any])', '->', 'Tuple[List[Annotation],', 'Any,', 'Any]:', '(hard_prediction,', 'soft_prediction)', '=', "self.model['decoder'].postprocess(prediction,", 'metadata)', 'annotation', '=', 'self.converter.convert_to_annotat... | 918,390 |
openvinotoolkit/training_extensions | openvino.py | OpenVINOVisualPromptingInferencer.forward | forward | Forward function of OpenVINO Visual Prompting Inferencer. | [
"Forward",
"function",
"of",
"OpenVINO",
"Visual",
"Prompting",
"Inferencer."
] | def forward(self, inputs: Dict[str, np.ndarray]) -> Dict[str, np.ndarray]:
return self.model['image_encoder'].infer_sync(inputs) | ['def', 'forward(self,', 'inputs:', 'Dict[str,', 'np.ndarray])', '->', 'Dict[str,', 'np.ndarray]:', 'return', "self.model['image_encoder'].infer_sync(inputs)"] | 918,392 |
openvinotoolkit/training_extensions | openvino.py | OpenVINOVisualPromptingTask.hparams | hparams | Hparams of OpenVINO Visual Prompting Task. | [
"Hparams",
"of",
"OpenVINO",
"Visual",
"Prompting",
"Task."
] | def hparams(self):
return self.task_environment.get_hyper_parameters(VisualPromptingBaseConfig) | ['def', 'hparams(self):', 'return', 'self.task_environment.get_hyper_parameters(VisualPromptingBaseConfig)'] | 918,395 |
openvinotoolkit/training_extensions | openvino.py | OpenVINOVisualPromptingTask.load_inferencer | load_inferencer | Load OpenVINO Visual Prompting Inferencer. | [
"Load",
"OpenVINO",
"Visual",
"Prompting",
"Inferencer."
] | def load_inferencer(self) -> OpenVINOVisualPromptingInferencer:
if self.model is None:
raise RuntimeError('load_inferencer failed, model is None')
return OpenVINOVisualPromptingInferencer(self.hparams, self.task_environment.label_schema, {'image_encoder': self.model.get_data('visual_prompting_image_enco... | ['def', 'load_inferencer(self)', '->', 'OpenVINOVisualPromptingInferencer:', 'if', 'self.model', 'is', 'None:', 'raise', "RuntimeError('load_inferencer", 'failed,', 'model', 'is', "None')", 'return', 'OpenVINOVisualPromptingInferencer(self.hparams,', 'self.task_environment.label_schema,', "{'image_encoder':", "self.mod... | 918,396 |
openvinotoolkit/training_extensions | openvino.py | OpenVINOVisualPromptingTask.deploy | deploy | Deploy function of OpenVINOVisualPromptingTask. | [
"Deploy",
"function",
"of",
"OpenVINOVisualPromptingTask."
] | def deploy(self, output_model: ModelEntity) -> None:
logger.info('Deploying the model')
if self.model is None:
raise RuntimeError('deploy failed, model is None')
work_dir = os.path.dirname(demo.__file__)
parameters = {}
parameters['converter_type'] = f'{self.task_type}'
parameters['model... | ['def', 'deploy(self,', 'output_model:', 'ModelEntity)', '->', 'None:', "logger.info('Deploying", 'the', "model')", 'if', 'self.model', 'is', 'None:', 'raise', "RuntimeError('deploy", 'failed,', 'model', 'is', "None')", 'work_dir', '=', 'os.path.dirname(demo.__file__)', 'parameters', '=', '{}', "parameters['converter_t... | 918,399 |
openvinotoolkit/training_extensions | openvino.py | OpenVINOVisualPromptingTask.optimize | optimize | Optimize function of OpenVINOVisualPromptingTask. | [
"Optimize",
"function",
"of",
"OpenVINOVisualPromptingTask."
] | def optimize(self, optimization_type: OptimizationType, dataset: DatasetEntity, output_model: ModelEntity, optimization_parameters: Optional[OptimizationParameters]=None):
logger.info('Start PTQ optimization')
if self.model is None:
raise RuntimeError('PTQ optimize failed, model is None')
if optimiz... | ['def', 'optimize(self,', 'optimization_type:', 'OptimizationType,', 'dataset:', 'DatasetEntity,', 'output_model:', 'ModelEntity,', 'optimization_parameters:', 'Optional[OptimizationParameters]=None):', "logger.info('Start", 'PTQ', "optimization')", 'if', 'self.model', 'is', 'None:', 'raise', "RuntimeError('PTQ", 'opti... | 918,400 |
openvinotoolkit/training_extensions | visual_prompting_utils.py | get_visual_prompting_inferencer_configuration | get_visual_prompting_inferencer_configuration | Get visual prompting inferencer config by label schema. | [
"Get",
"visual",
"prompting",
"inferencer",
"config",
"by",
"label",
"schema."
] | def get_visual_prompting_inferencer_configuration(label_schema: LabelSchemaEntity):
return {} | ['def', 'get_visual_prompting_inferencer_configuration(label_schema:', 'LabelSchemaEntity):', 'return', '{}'] | 918,401 |
openvinotoolkit/training_extensions | metadata_keys.py | allows_dictionary_values | allows_dictionary_values | Returns True if the metadata element described by `keyword` allows having a dictionary as its value. | [
"Returns",
"True",
"if",
"the",
"metadata",
"element",
"described",
"by",
"`keyword`",
"allows",
"having",
"a",
"dictionary",
"as",
"its",
"value."
] | def allows_dictionary_values(keyword: str) -> bool:
keys_allowing_dictionary_values = [OPTIONS, UI_RULES]
return keyword in keys_allowing_dictionary_values | ['def', 'allows_dictionary_values(keyword:', 'str)', '->', 'bool:', 'keys_allowing_dictionary_values', '=', '[OPTIONS,', 'UI_RULES]', 'return', 'keyword', 'in', 'keys_allowing_dictionary_values'] | 918,406 |
openvinotoolkit/training_extensions | primitive_parameters.py | set_common_metadata | set_common_metadata | Function to construct the dictionary of metadata that is common for all parameter types. | [
"Function",
"to",
"construct",
"the",
"dictionary",
"of",
"metadata",
"that",
"is",
"common",
"for",
"all",
"parameter",
"types."
] | def set_common_metadata(default_value: Union[int, float, str, bool, ConfigurableEnum], header: str, description: str, warning: Optional[str], editable: bool, affects_outcome_of: ModelLifecycle, ui_rules: UIRules, visible_in_ui: bool, parameter_type: ConfigElementType, auto_hpo_state: AutoHPOState, auto_hpo_value: Optio... | ['def', 'set_common_metadata(default_value:', 'Union[int,', 'float,', 'str,', 'bool,', 'ConfigurableEnum],', 'header:', 'str,', 'description:', 'str,', 'warning:', 'Optional[str],', 'editable:', 'bool,', 'affects_outcome_of:', 'ModelLifecycle,', 'ui_rules:', 'UIRules,', 'visible_in_ui:', 'bool,', 'parameter_type:', 'Co... | 918,412 |
openvinotoolkit/training_extensions | primitive_parameters.py | configurable_float | configurable_float | Constructs a configurable float attribute, with the appropriate metadata. | [
"Constructs",
"a",
"configurable",
"float",
"attribute,",
"with",
"the",
"appropriate",
"metadata."
] | def configurable_float(default_value: float, header: str, min_value: float=0.0, max_value: float=255.0, step_size: Optional[float]=None, description: str='Default float description', warning: str=None, editable: bool=True, visible_in_ui: bool=True, affects_outcome_of: ModelLifecycle=ModelLifecycle.NONE, ui_rules: UIRul... | ['def', 'configurable_float(default_value:', 'float,', 'header:', 'str,', 'min_value:', 'float=0.0,', 'max_value:', 'float=255.0,', 'step_size:', 'Optional[float]=None,', 'description:', "str='Default", 'float', "description',", 'warning:', 'str=None,', 'editable:', 'bool=True,', 'visible_in_ui:', 'bool=True,', 'affect... | 918,414 |
openvinotoolkit/training_extensions | utils.py | construct_attr_value_validator | construct_attr_value_validator | Constructs a validator function that is used in the attribute validation of numeric configurable parameters. | [
"Constructs",
"a",
"validator",
"function",
"that",
"is",
"used",
"in",
"the",
"attribute",
"validation",
"of",
"numeric",
"configurable",
"parameters."
] | def construct_attr_value_validator(min_value: NumericTypeVar, max_value: NumericTypeVar) -> Callable[[ParameterGroup, Attribute, NumericTypeVar], None]:
def attr_validate_value(instance: ParameterGroup, attribute: Attribute, value: NumericTypeVar):
if not min_value <= value <= max_value:
raise ... | ['def', 'construct_attr_value_validator(min_value:', 'NumericTypeVar,', 'max_value:', 'NumericTypeVar)', '->', 'Callable[[ParameterGroup,', 'Attribute,', 'NumericTypeVar],', 'None]:', 'def', 'attr_validate_value(instance:', 'ParameterGroup,', 'attribute:', 'Attribute,', 'value:', 'NumericTypeVar):', 'if', 'not', 'min_v... | 918,423 |
openvinotoolkit/training_extensions | utils.py | construct_attr_selectable_validator | construct_attr_selectable_validator | Constructs a validator function that is used in the attribute validation of selectable configurable parameters. | [
"Constructs",
"a",
"validator",
"function",
"that",
"is",
"used",
"in",
"the",
"attribute",
"validation",
"of",
"selectable",
"configurable",
"parameters."
] | def construct_attr_selectable_validator(options: List[SelectableTypeVar]) -> Callable[[ParameterGroup, Attribute, SelectableTypeVar], None]:
def attr_validate_selectable(instance: ParameterGroup, attribute: Attribute, value: SelectableTypeVar):
if value not in options:
raise ValueError(f'Invali... | ['def', 'construct_attr_selectable_validator(options:', 'List[SelectableTypeVar])', '->', 'Callable[[ParameterGroup,', 'Attribute,', 'SelectableTypeVar],', 'None]:', 'def', 'attr_validate_selectable(instance:', 'ParameterGroup,', 'attribute:', 'Attribute,', 'value:', 'SelectableTypeVar):', 'if', 'value', 'not', 'in', '... | 918,424 |
openvinotoolkit/training_extensions | utils.py | attr_strict_float_on_setattr | attr_strict_float_on_setattr | Validate that the value set for an attribute is a float, or a number that can be converted to a float. | [
"Validate",
"that",
"the",
"value",
"set",
"for",
"an",
"attribute",
"is",
"a",
"float,",
"or",
"a",
"number",
"that",
"can",
"be",
"converted",
"to",
"a",
"float."
] | def attr_strict_float_on_setattr(instance: ParameterGroup, attribute: Attribute, value: float) -> float:
float_value = _validate_and_convert_float(value)
if float_value is None:
raise TypeError(f"Invalid argument type for {attribute.name}: {value} is not of type 'float'")
return float_value | ['def', 'attr_strict_float_on_setattr(instance:', 'ParameterGroup,', 'attribute:', 'Attribute,', 'value:', 'float)', '->', 'float:', 'float_value', '=', '_validate_and_convert_float(value)', 'if', 'float_value', 'is', 'None:', 'raise', 'TypeError(f"Invalid', 'argument', 'type', 'for', '{attribute.name}:', '{value}', 'i... | 918,427 |
openvinotoolkit/training_extensions | utils.py | attr_strict_float_converter | attr_strict_float_converter | Converts a value to float. | [
"Converts",
"a",
"value",
"to",
"float."
] | def attr_strict_float_converter(value: float) -> float:
float_value = _validate_and_convert_float(value)
if float_value is None:
raise TypeError(f'Invalid value passed for parameter. Value {value} of type {type(value)} is not a float.')
return float_value | ['def', 'attr_strict_float_converter(value:', 'float)', '->', 'float:', 'float_value', '=', '_validate_and_convert_float(value)', 'if', 'float_value', 'is', 'None:', 'raise', "TypeError(f'Invalid", 'value', 'passed', 'for', 'parameter.', 'Value', '{value}', 'of', 'type', '{type(value)}', 'is', 'not', 'a', "float.')", '... | 918,428 |
openvinotoolkit/training_extensions | utils.py | get_enum_names | get_enum_names | Returns a list containing the names of all members of the Enum class passed as `enum_cls`. | [
"Returns",
"a",
"list",
"containing",
"the",
"names",
"of",
"all",
"members",
"of",
"the",
"Enum",
"class",
"passed",
"as",
"`enum_cls`."
] | def get_enum_names(enum_cls: Type[Enum]) -> List[str]:
return [member.name for member in enum_cls] | ['def', 'get_enum_names(enum_cls:', 'Type[Enum])', '->', 'List[str]:', 'return', '[member.name', 'for', 'member', 'in', 'enum_cls]'] | 918,430 |
openvinotoolkit/training_extensions | convert.py | parameter_group_to_dict | parameter_group_to_dict | Converts an instance of a `ParameterGroup` configuration element to its dictionary representation. | [
"Converts",
"an",
"instance",
"of",
"a",
"`ParameterGroup`",
"configuration",
"element",
"to",
"its",
"dictionary",
"representation."
] | def parameter_group_to_dict(parameter_group: ParameterGroup, enum_to_str: bool=False, values_only: bool=False) -> dict:
parameter_group.update_auto_hpo_states()
attribute_names = [attribute.name for attribute in parameter_group.__attrs_attrs__]
attribute_values = [getattr(parameter_group, attribute_name) fo... | ['def', 'parameter_group_to_dict(parameter_group:', 'ParameterGroup,', 'enum_to_str:', 'bool=False,', 'values_only:', 'bool=False)', '->', 'dict:', 'parameter_group.update_auto_hpo_states()', 'attribute_names', '=', '[attribute.name', 'for', 'attribute', 'in', 'parameter_group.__attrs_attrs__]', 'attribute_values', '='... | 918,432 |
openvinotoolkit/training_extensions | create.py | create | create | Create a configuration object from a yaml string, yaml file path, dictionary or OmegaConf DictConfig object. | [
"Create",
"a",
"configuration",
"object",
"from",
"a",
"yaml",
"string,",
"yaml",
"file",
"path,",
"dictionary",
"or",
"OmegaConf",
"DictConfig",
"object."
] | def create(input_config: Union[str, DictConfig, dict]) -> ConfigurableParameters:
config_dict = input_to_config_dict(copy.deepcopy(input_config))
config: ConfigurableParameters = from_dict_attr(config_dict)
return config | ['def', 'create(input_config:', 'Union[str,', 'DictConfig,', 'dict])', '->', 'ConfigurableParameters:', 'config_dict', '=', 'input_to_config_dict(copy.deepcopy(input_config))', 'config:', 'ConfigurableParameters', '=', 'from_dict_attr(config_dict)', 'return', 'config'] | 918,442 |
openvinotoolkit/training_extensions | utils.py | search_in_config_dict | search_in_config_dict | Recursively searches a config_dict for all instances of key_to_search and returns the key path to them. | [
"Recursively",
"searches",
"a",
"config_dict",
"for",
"all",
"instances",
"of",
"key_to_search",
"and",
"returns",
"the",
"key",
"path",
"to",
"them."
] | def search_in_config_dict(config_dict: dict, key_to_search: str) -> List[Tuple[Any, List[str]]]:
return _search_in_config_dict_inner(config_dict, key_to_search=key_to_search) | ['def', 'search_in_config_dict(config_dict:', 'dict,', 'key_to_search:', 'str)', '->', 'List[Tuple[Any,', 'List[str]]]:', 'return', '_search_in_config_dict_inner(config_dict,', 'key_to_search=key_to_search)'] | 918,445 |
openvinotoolkit/training_extensions | utils.py | flatten_detection_config_groups | flatten_detection_config_groups | Converts all Detection Config Group objects in a config dictionary to their dictionary representation. | [
"Converts",
"all",
"Detection",
"Config",
"Group",
"objects",
"in",
"a",
"config",
"dictionary",
"to",
"their",
"dictionary",
"representation."
] | def flatten_detection_config_groups(config: dict):
for (key, value) in config.items():
if hasattr(value, '__dict__'):
config[key] = value.__dict__
elif isinstance(value, dict):
flatten_detection_config_groups(value) | ['def', 'flatten_detection_config_groups(config:', 'dict):', 'for', '(key,', 'value)', 'in', 'config.items():', 'if', 'hasattr(value,', "'__dict__'):", 'config[key]', '=', 'value.__dict__', 'elif', 'isinstance(value,', 'dict):', 'flatten_detection_config_groups(value)'] | 918,451 |
openvinotoolkit/training_extensions | rules.py | Rule.to_dict | to_dict | Method to serialize a Rule instance to its dictionary representation. | [
"Method",
"to",
"serialize",
"a",
"Rule",
"instance",
"to",
"its",
"dictionary",
"representation."
] | def to_dict(self, enum_to_str: bool=True) -> dict:
if enum_to_str:
serializer: Optional[Callable] = attr_enum_to_str_serializer
else:
serializer = None
return asdict(self, value_serializer=serializer) | ['def', 'to_dict(self,', 'enum_to_str:', 'bool=True)', '->', 'dict:', 'if', 'enum_to_str:', 'serializer:', 'Optional[Callable]', '=', 'attr_enum_to_str_serializer', 'else:', 'serializer', '=', 'None', 'return', 'asdict(self,', 'value_serializer=serializer)'] | 918,454 |
openvinotoolkit/training_extensions | annotation.py | Annotation.id_ | id_ | Returns the id for the annotation. | [
"Returns",
"the",
"id",
"for",
"the",
"annotation."
] | def id_(self):
return self.__id_ | ['def', 'id_(self):', 'return', 'self.__id_'] | 918,458 |
openvinotoolkit/training_extensions | annotation.py | Annotation.shape | shape | Returns the shape that is in the annotation. | [
"Returns",
"the",
"shape",
"that",
"is",
"in",
"the",
"annotation."
] | def shape(self) -> ShapeEntity:
return self.__shape | ['def', 'shape(self)', '->', 'ShapeEntity:', 'return', 'self.__shape'] | 918,459 |
openvinotoolkit/training_extensions | annotation.py | Annotation.get_labels | get_labels | Get scored labels that are assigned to this annotation. | [
"Get",
"scored",
"labels",
"that",
"are",
"assigned",
"to",
"this",
"annotation."
] | def get_labels(self, include_empty: bool=False) -> List[ScoredLabel]:
return [label for label in self.__labels if include_empty or not label.is_empty] | ['def', 'get_labels(self,', 'include_empty:', 'bool=False)', '->', 'List[ScoredLabel]:', 'return', '[label', 'for', 'label', 'in', 'self.__labels', 'if', 'include_empty', 'or', 'not', 'label.is_empty]'] | 918,460 |
openvinotoolkit/training_extensions | annotation.py | Annotation.get_label_ids | get_label_ids | Get a set of ID's of labels that are assigned to this annotation. | [
"Get",
"a",
"set",
"of",
"ID's",
"of",
"labels",
"that",
"are",
"assigned",
"to",
"this",
"annotation."
] | def get_label_ids(self, include_empty: bool=False) -> Set[ID]:
return {label.id_ for label in self.__labels if include_empty or not label.is_empty} | ['def', 'get_label_ids(self,', 'include_empty:', 'bool=False)', '->', 'Set[ID]:', 'return', '{label.id_', 'for', 'label', 'in', 'self.__labels', 'if', 'include_empty', 'or', 'not', 'label.is_empty}'] | 918,461 |
openvinotoolkit/training_extensions | annotation.py | Annotation.append_label | append_label | Appends the scored label to the annotation. | [
"Appends",
"the",
"scored",
"label",
"to",
"the",
"annotation."
] | def append_label(self, label: ScoredLabel) -> None:
self.__labels.append(label) | ['def', 'append_label(self,', 'label:', 'ScoredLabel)', '->', 'None:', 'self.__labels.append(label)'] | 918,462 |
openvinotoolkit/training_extensions | annotation.py | Annotation.set_labels | set_labels | Sets the labels of the annotation to be the input of the function. | [
"Sets",
"the",
"labels",
"of",
"the",
"annotation",
"to",
"be",
"the",
"input",
"of",
"the",
"function."
] | def set_labels(self, labels: List[ScoredLabel]) -> None:
self.__labels = labels | ['def', 'set_labels(self,', 'labels:', 'List[ScoredLabel])', '->', 'None:', 'self.__labels', '=', 'labels'] | 918,463 |
openvinotoolkit/training_extensions | annotation.py | AnnotationSceneEntity.id_ | id_ | Returns the ID of the AnnotationSceneEntity. | [
"Returns",
"the",
"ID",
"of",
"the",
"AnnotationSceneEntity."
] | def id_(self) -> ID:
return self.__id_ | ['def', 'id_(self)', '->', 'ID:', 'return', 'self.__id_'] | 918,464 |
openvinotoolkit/training_extensions | annotation.py | AnnotationSceneEntity.editor_name | editor_name | Returns the editor's name that made the AnnotationSceneEntity object. | [
"Returns",
"the",
"editor's",
"name",
"that",
"made",
"the",
"AnnotationSceneEntity",
"object."
] | def editor_name(self) -> str:
return self.__editor | ['def', 'editor_name(self)', '->', 'str:', 'return', 'self.__editor'] | 918,466 |
openvinotoolkit/training_extensions | annotation.py | AnnotationSceneEntity.creation_date | creation_date | Returns the creation date of the AnnotationSceneEntity object. | [
"Returns",
"the",
"creation",
"date",
"of",
"the",
"AnnotationSceneEntity",
"object."
] | def creation_date(self) -> datetime.datetime:
return self.__creation_date | ['def', 'creation_date(self)', '->', 'datetime.datetime:', 'return', 'self.__creation_date'] | 918,467 |
openvinotoolkit/training_extensions | annotation.py | AnnotationSceneEntity.shapes | shapes | Returns all shapes that are inside the annotations of the AnnotationSceneEntity. | [
"Returns",
"all",
"shapes",
"that",
"are",
"inside",
"the",
"annotations",
"of",
"the",
"AnnotationSceneEntity."
] | def shapes(self) -> List[ShapeEntity]:
return [annotation.shape for annotation in self.annotations] | ['def', 'shapes(self)', '->', 'List[ShapeEntity]:', 'return', '[annotation.shape', 'for', 'annotation', 'in', 'self.annotations]'] | 918,469 |
openvinotoolkit/training_extensions | annotation.py | AnnotationSceneEntity.get_labels | get_labels | Returns a list of unique labels which appear in this annotation scene. | [
"Returns",
"a",
"list",
"of",
"unique",
"labels",
"which",
"appear",
"in",
"this",
"annotation",
"scene."
] | def get_labels(self, include_empty: bool=False) -> List[LabelEntity]:
labels: Dict[str, LabelEntity] = {}
for annotation in self.annotations:
for label in annotation.get_labels(include_empty=include_empty):
id_ = label.id_
if id_ not in labels:
labels[id_] = label... | ['def', 'get_labels(self,', 'include_empty:', 'bool=False)', '->', 'List[LabelEntity]:', 'labels:', 'Dict[str,', 'LabelEntity]', '=', '{}', 'for', 'annotation', 'in', 'self.annotations:', 'for', 'label', 'in', 'annotation.get_labels(include_empty=include_empty):', 'id_', '=', 'label.id_', 'if', 'id_', 'not', 'in', 'lab... | 918,473 |
openvinotoolkit/training_extensions | annotation.py | AnnotationSceneEntity.get_label_ids | get_label_ids | Returns a set of the ID's of unique labels which appear in this annotation scene. | [
"Returns",
"a",
"set",
"of",
"the",
"ID's",
"of",
"unique",
"labels",
"which",
"appear",
"in",
"this",
"annotation",
"scene."
] | def get_label_ids(self, include_empty: bool=False) -> Set[ID]:
output: Set[ID] = set()
for annotation in self.annotations:
output.update(set(annotation.get_label_ids(include_empty=include_empty)))
return output | ['def', 'get_label_ids(self,', 'include_empty:', 'bool=False)', '->', 'Set[ID]:', 'output:', 'Set[ID]', '=', 'set()', 'for', 'annotation', 'in', 'self.annotations:', 'output.update(set(annotation.get_label_ids(include_empty=include_empty)))', 'return', 'output'] | 918,474 |
openvinotoolkit/training_extensions | color.py | ColorEntity.red | red | Returns the red color value for the ColorEntity object. | [
"Returns",
"the",
"red",
"color",
"value",
"for",
"the",
"ColorEntity",
"object."
] | def red(self) -> int:
return self.__red | ['def', 'red(self)', '->', 'int:', 'return', 'self.__red'] | 918,475 |
openvinotoolkit/training_extensions | color.py | ColorEntity.green | green | Returns the green color value for the ColorEntity object. | [
"Returns",
"the",
"green",
"color",
"value",
"for",
"the",
"ColorEntity",
"object."
] | def green(self) -> int:
return self.__green | ['def', 'green(self)', '->', 'int:', 'return', 'self.__green'] | 918,476 |
openvinotoolkit/training_extensions | color.py | ColorEntity.alpha | alpha | Returns the alpha value for the ColorEntity object. | [
"Returns",
"the",
"alpha",
"value",
"for",
"the",
"ColorEntity",
"object."
] | def alpha(self) -> int:
return self.__alpha | ['def', 'alpha(self)', '->', 'int:', 'return', 'self.__alpha'] | 918,478 |
openvinotoolkit/training_extensions | color.py | ColorEntity.from_hex_str | from_hex_str | Converts a hex string to a color. | [
"Converts",
"a",
"hex",
"string",
"to",
"a",
"color."
] | def from_hex_str(cls, string: str):
raise NotImplementedError | ['def', 'from_hex_str(cls,', 'string:', 'str):', 'raise', 'NotImplementedError'] | 918,480 |
openvinotoolkit/training_extensions | color.py | ColorEntity.random | random | Generates a random Color. | [
"Generates",
"a",
"random",
"Color."
] | def random(cls):
raise NotImplementedError | ['def', 'random(cls):', 'raise', 'NotImplementedError'] | 918,481 |
openvinotoolkit/training_extensions | color.py | Color.hex_str | hex_str | Returns the color in a Hex representation. | [
"Returns",
"the",
"color",
"in",
"a",
"Hex",
"representation."
] | def hex_str(self) -> str:
return f'#{self.red:02x}{self.green:02x}{self.blue:02x}{self.alpha:02x}' | ['def', 'hex_str(self)', '->', 'str:', 'return', "f'#{self.red:02x}{self.green:02x}{self.blue:02x}{self.alpha:02x}'"] | 918,482 |
openvinotoolkit/training_extensions | datasets.py | DatasetEntity.remove_at_indices | remove_at_indices | Delete items based on the `indices`. | [
"Delete",
"items",
"based",
"on",
"the",
"`indices`."
] | def remove_at_indices(self, indices: List[int]) -> None:
indices.sort(reverse=True)
for i_item in indices:
del self._items[i_item] | ['def', 'remove_at_indices(self,', 'indices:', 'List[int])', '->', 'None:', 'indices.sort(reverse=True)', 'for', 'i_item', 'in', 'indices:', 'del', 'self._items[i_item]'] | 918,496 |
openvinotoolkit/training_extensions | dataset_item.py | DatasetItemEntity.ignored_labels | ignored_labels | Get the IDs of the labels to ignore in this dataset item. | [
"Get",
"the",
"IDs",
"of",
"the",
"labels",
"to",
"ignore",
"in",
"this",
"dataset",
"item."
] | def ignored_labels(self) -> Set[LabelEntity]:
return self.__ignored_labels | ['def', 'ignored_labels(self)', '->', 'Set[LabelEntity]:', 'return', 'self.__ignored_labels'] | 918,498 |
openvinotoolkit/training_extensions | dataset_item.py | DatasetItemEntity.height | height | The height of the dataset item, taking into account the ROI. | [
"The",
"height",
"of",
"the",
"dataset",
"item,",
"taking",
"into",
"account",
"the",
"ROI."
] | def height(self) -> int:
roi_shape_as_box = ShapeFactory.shape_as_rectangle(self.roi.shape)
roi_shape_as_box = roi_shape_as_box.clip_to_visible_region()
height = self.media.height
y1 = int(round(roi_shape_as_box.y1 * height))
y2 = int(round(roi_shape_as_box.y2 * height))
return y2 - y1 | ['def', 'height(self)', '->', 'int:', 'roi_shape_as_box', '=', 'ShapeFactory.shape_as_rectangle(self.roi.shape)', 'roi_shape_as_box', '=', 'roi_shape_as_box.clip_to_visible_region()', 'height', '=', 'self.media.height', 'y1', '=', 'int(round(roi_shape_as_box.y1', '*', 'height))', 'y2', '=', 'int(round(roi_shape_as_box.... | 918,503 |
openvinotoolkit/training_extensions | dataset_item.py | DatasetItemEntity.append_labels | append_labels | Appends labels to the DatasetItem and adds it to the the annotation label as well if it's not yet there. | [
"Appends",
"labels",
"to",
"the",
"DatasetItem",
"and",
"adds",
"it",
"to",
"the",
"the",
"annotation",
"label",
"as",
"well",
"if",
"it's",
"not",
"yet",
"there."
] | def append_labels(self, labels: List[ScoredLabel]):
if len(labels) == 0:
return
roi_annotation = None
for annotation in self.annotation_scene.annotations:
if annotation.shape == self.roi.shape:
roi_annotation = annotation
break
if roi_annotation is None:
r... | ['def', 'append_labels(self,', 'labels:', 'List[ScoredLabel]):', 'if', 'len(labels)', '==', '0:', 'return', 'roi_annotation', '=', 'None', 'for', 'annotation', 'in', 'self.annotation_scene.annotations:', 'if', 'annotation.shape', '==', 'self.roi.shape:', 'roi_annotation', '=', 'annotation', 'break', 'if', 'roi_annotati... | 918,509 |
openvinotoolkit/training_extensions | dataset_item.py | DatasetItemEntity.wrap | wrap | Creates a new DatasetItemEntity, overriding only the given arguments to the existing ones for this instance. | [
"Creates",
"a",
"new",
"DatasetItemEntity,",
"overriding",
"only",
"the",
"given",
"arguments",
"to",
"the",
"existing",
"ones",
"for",
"this",
"instance."
] | def wrap(self: T, **kwargs) -> T:
params = {name: getattr(self, name) for name in signature(self.__class__.__init__).parameters.keys() if hasattr(self, name)}
params.update({'metadata': self.get_metadata()})
params.update(**kwargs)
return self.__class__(**params) | ['def', 'wrap(self:', 'T,', '**kwargs)', '->', 'T:', 'params', '=', '{name:', 'getattr(self,', 'name)', 'for', 'name', 'in', 'signature(self.__class__.__init__).parameters.keys()', 'if', 'hasattr(self,', 'name)}', "params.update({'metadata':", 'self.get_metadata()})', 'params.update(**kwargs)', 'return', 'self.__class_... | 918,511 |
openvinotoolkit/training_extensions | graph.py | Graph.set_graph | set_graph | Set the underlying NetworkX graph. | [
"Set",
"the",
"underlying",
"NetworkX",
"graph."
] | def set_graph(self, graph: Union[nx.Graph, nx.MultiDiGraph]):
self._graph = graph | ['def', 'set_graph(self,', 'graph:', 'Union[nx.Graph,', 'nx.MultiDiGraph]):', 'self._graph', '=', 'graph'] | 918,515 |
openvinotoolkit/training_extensions | graph.py | Graph.add_edge | add_edge | Adds edge between node1 and node2. | [
"Adds",
"edge",
"between",
"node1",
"and",
"node2."
] | def add_edge(self, node1, node2, edge_value=None):
self._graph.add_edge(node1, node2, value=edge_value) | ['def', 'add_edge(self,', 'node1,', 'node2,', 'edge_value=None):', 'self._graph.add_edge(node1,', 'node2,', 'value=edge_value)'] | 918,516 |
openvinotoolkit/training_extensions | graph.py | Graph.num_nodes | num_nodes | Returns the number of nodes in the graph. | [
"Returns",
"the",
"number",
"of",
"nodes",
"in",
"the",
"graph."
] | def num_nodes(self) -> int:
return self._graph.number_of_nodes() | ['def', 'num_nodes(self)', '->', 'int:', 'return', 'self._graph.number_of_nodes()'] | 918,517 |
openvinotoolkit/training_extensions | graph.py | Graph.find_in_edges | find_in_edges | Returns the edges that have `node` as a source. | [
"Returns",
"the",
"edges",
"that",
"have",
"`node`",
"as",
"a",
"source."
] | def find_in_edges(self, node):
if node not in self._graph.nodes:
raise KeyError(f'The node `{node}` is not part of the graph')
if isinstance(self._graph, nx.MultiDiGraph):
return self._graph.in_edges(node)
return [] | ['def', 'find_in_edges(self,', 'node):', 'if', 'node', 'not', 'in', 'self._graph.nodes:', 'raise', "KeyError(f'The", 'node', '`{node}`', 'is', 'not', 'part', 'of', 'the', "graph')", 'if', 'isinstance(self._graph,', 'nx.MultiDiGraph):', 'return', 'self._graph.in_edges(node)', 'return', '[]'] | 918,522 |
openvinotoolkit/training_extensions | graph.py | Graph.find_cliques | find_cliques | Returns cliques in the graph. | [
"Returns",
"cliques",
"in",
"the",
"graph."
] | def find_cliques(self):
return nx.algorithms.clique.find_cliques(self._graph) | ['def', 'find_cliques(self):', 'return', 'nx.algorithms.clique.find_cliques(self._graph)'] | 918,523 |
openvinotoolkit/training_extensions | graph.py | Graph.edges | edges | Returns all the edges in the graph. | [
"Returns",
"all",
"the",
"edges",
"in",
"the",
"graph."
] | def edges(self):
if isinstance(self._graph, nx.MultiDiGraph):
all_edges = self._graph.edges(keys=True, data=True)
else:
all_edges = self._graph.edges(data=True)
return all_edges | ['def', 'edges(self):', 'if', 'isinstance(self._graph,', 'nx.MultiDiGraph):', 'all_edges', '=', 'self._graph.edges(keys=True,', 'data=True)', 'else:', 'all_edges', '=', 'self._graph.edges(data=True)', 'return', 'all_edges'] | 918,525 |
openvinotoolkit/training_extensions | graph.py | Graph.num_labels | num_labels | Returns the number of labels in the graph. | [
"Returns",
"the",
"number",
"of",
"labels",
"in",
"the",
"graph."
] | def num_labels(self):
return nx.convert_matrix.to_numpy_matrix(self._graph).shape[0] | ['def', 'num_labels(self):', 'return', 'nx.convert_matrix.to_numpy_matrix(self._graph).shape[0]'] | 918,526 |
openvinotoolkit/training_extensions | graph.py | MultiDiGraph.topological_sort | topological_sort | Returns a generator of nodes in topologically sorted order. | [
"Returns",
"a",
"generator",
"of",
"nodes",
"in",
"topologically",
"sorted",
"order."
] | def topological_sort(self):
return nx.topological_sort(self._graph) | ['def', 'topological_sort(self):', 'return', 'nx.topological_sort(self._graph)'] | 918,530 |
openvinotoolkit/training_extensions | id.py | ID.representation | representation | Returns the value of the identifier. | [
"Returns",
"the",
"value",
"of",
"the",
"identifier."
] | def representation(self):
return self | ['def', 'representation(self):', 'return', 'self'] | 918,531 |
openvinotoolkit/training_extensions | image.py | Image.width | width | Returns the width of the image. | [
"Returns",
"the",
"width",
"of",
"the",
"image."
] | def width(self) -> int:
if self.__width is None:
(self.__height, self.__width) = self.__get_size()
return self.__width | ['def', 'width(self)', '->', 'int:', 'if', 'self.__width', 'is', 'None:', '(self.__height,', 'self.__width)', '=', 'self.__get_size()', 'return', 'self.__width'] | 918,535 |
openvinotoolkit/training_extensions | label.py | LabelEntity.name | name | Returns the label name. | [
"Returns",
"the",
"label",
"name."
] | def name(self):
return self._name | ['def', 'name(self):', 'return', 'self._name'] | 918,537 |
openvinotoolkit/training_extensions | label.py | LabelEntity.hotkey | hotkey | Returns the hotkey for the label. | [
"Returns",
"the",
"hotkey",
"for",
"the",
"label."
] | def hotkey(self) -> str:
return self._hotkey | ['def', 'hotkey(self)', '->', 'str:', 'return', 'self._hotkey'] | 918,539 |
openvinotoolkit/training_extensions | label.py | LabelEntity.domain | domain | Returns the algorithm domain associated to this label. | [
"Returns",
"the",
"algorithm",
"domain",
"associated",
"to",
"this",
"label."
] | def domain(self):
return self._domain | ['def', 'domain(self):', 'return', 'self._domain'] | 918,540 |
openvinotoolkit/training_extensions | label.py | LabelEntity.creation_date | creation_date | Returns the creation date of the label. | [
"Returns",
"the",
"creation",
"date",
"of",
"the",
"label."
] | def creation_date(self) -> datetime.datetime:
return self._creation_date | ['def', 'creation_date(self)', '->', 'datetime.datetime:', 'return', 'self._creation_date'] | 918,542 |
openvinotoolkit/training_extensions | label.py | LabelEntity.id_ | id_ | Returns the label id. | [
"Returns",
"the",
"label",
"id."
] | def id_(self) -> ID:
return self.__id_ | ['def', 'id_(self)', '->', 'ID:', 'return', 'self.__id_'] | 918,543 |
openvinotoolkit/training_extensions | label_schema.py | LabelGroup.remove_label | remove_label | Remove label from label group if it exists in the group. | [
"Remove",
"label",
"from",
"label",
"group",
"if",
"it",
"exists",
"in",
"the",
"group."
] | def remove_label(self, label: LabelEntity) -> None:
if label in self.labels:
self.labels.remove(label) | ['def', 'remove_label(self,', 'label:', 'LabelEntity)', '->', 'None:', 'if', 'label', 'in', 'self.labels:', 'self.labels.remove(label)'] | 918,546 |
openvinotoolkit/training_extensions | label_schema.py | LabelTree.add_node | add_node | Add node to the tree. | [
"Add",
"node",
"to",
"the",
"tree."
] | def add_node(self, node):
super().add_node(node)
self.clear_topological_cache() | ['def', 'add_node(self,', 'node):', 'super().add_node(node)', 'self.clear_topological_cache()'] | 918,549 |
openvinotoolkit/training_extensions | label_schema.py | LabelTree.add_edges | add_edges | Add edges between Labels. | [
"Add",
"edges",
"between",
"Labels."
] | def add_edges(self, edges):
self._graph.add_edges_from(edges)
self.clear_topological_cache() | ['def', 'add_edges(self,', 'edges):', 'self._graph.add_edges_from(edges)', 'self.clear_topological_cache()'] | 918,550 |
openvinotoolkit/training_extensions | label_schema.py | LabelTree.type | type | Returns the type of the LabelTree. | [
"Returns",
"the",
"type",
"of",
"the",
"LabelTree."
] | def type(self):
return 'tree' | ['def', 'type(self):', 'return', "'tree'"] | 918,555 |
openvinotoolkit/training_extensions | label_schema.py | LabelTree.get_siblings | get_siblings | Returns the siblings of a label. | [
"Returns",
"the",
"siblings",
"of",
"a",
"label."
] | def get_siblings(self, label: LabelEntity) -> List[LabelEntity]:
parent = self.get_parent(label)
if parent is None:
siblings = []
else:
siblings = [u for (u, v) in self._graph.in_edges(parent) if u != label]
return siblings | ['def', 'get_siblings(self,', 'label:', 'LabelEntity)', '->', 'List[LabelEntity]:', 'parent', '=', 'self.get_parent(label)', 'if', 'parent', 'is', 'None:', 'siblings', '=', '[]', 'else:', 'siblings', '=', '[u', 'for', '(u,', 'v)', 'in', 'self._graph.in_edges(parent)', 'if', 'u', '!=', 'label]', 'return', 'siblings'] | 918,560 |
openvinotoolkit/training_extensions | label_schema.py | LabelTree.get_ancestors | get_ancestors | Returns ancestors of `label`, including self. | [
"Returns",
"ancestors",
"of",
"`label`,",
"including",
"self."
] | def get_ancestors(self, label: LabelEntity) -> List[LabelEntity]:
result = []
parent: Optional[LabelEntity] = label
while parent is not None:
result.append(parent)
parent = self.get_parent(parent)
return result | ['def', 'get_ancestors(self,', 'label:', 'LabelEntity)', '->', 'List[LabelEntity]:', 'result', '=', '[]', 'parent:', 'Optional[LabelEntity]', '=', 'label', 'while', 'parent', 'is', 'not', 'None:', 'result.append(parent)', 'parent', '=', 'self.get_parent(parent)', 'return', 'result'] | 918,561 |
openvinotoolkit/training_extensions | label_schema.py | LabelTree.subgraph | subgraph | Return the subgraph containing the given labels. | [
"Return",
"the",
"subgraph",
"containing",
"the",
"given",
"labels."
] | def subgraph(self, labels: Sequence[LabelEntity]) -> 'LabelTree':
new_graph = LabelTree()
new_graph.set_graph(self.get_graph().subgraph(labels).copy())
return new_graph | ['def', 'subgraph(self,', 'labels:', 'Sequence[LabelEntity])', '->', "'LabelTree':", 'new_graph', '=', 'LabelTree()', 'new_graph.set_graph(self.get_graph().subgraph(labels).copy())', 'return', 'new_graph'] | 918,562 |
openvinotoolkit/training_extensions | label_schema.py | LabelSchemaEntity.get_labels | get_labels | Get the labels in the label schema. | [
"Get",
"the",
"labels",
"in",
"the",
"label",
"schema."
] | def get_labels(self, include_empty: bool) -> List[LabelEntity]:
labels = {label for group in self._groups for label in group.labels if include_empty or not label.is_empty}
return sorted(list(labels), key=natural_sort_label_id) | ['def', 'get_labels(self,', 'include_empty:', 'bool)', '->', 'List[LabelEntity]:', 'labels', '=', '{label', 'for', 'group', 'in', 'self._groups', 'for', 'label', 'in', 'group.labels', 'if', 'include_empty', 'or', 'not', 'label.is_empty}', 'return', 'sorted(list(labels),', 'key=natural_sort_label_id)'] | 918,563 |
openvinotoolkit/training_extensions | label_schema.py | LabelSchemaEntity.get_label_group_by_name | get_label_group_by_name | Get the label group by the passed group_name. | [
"Get",
"the",
"label",
"group",
"by",
"the",
"passed",
"group_name."
] | def get_label_group_by_name(self, group_name: str) -> Optional[LabelGroup]:
for label_group in self._groups:
if group_name == label_group.name:
return label_group
return None | ['def', 'get_label_group_by_name(self,', 'group_name:', 'str)', '->', 'Optional[LabelGroup]:', 'for', 'label_group', 'in', 'self._groups:', 'if', 'group_name', '==', 'label_group.name:', 'return', 'label_group', 'return', 'None'] | 918,569 |
openvinotoolkit/training_extensions | label_schema.py | LabelSchemaEntity.get_exclusive_groups | get_exclusive_groups | Returns exclusive groups in the LabelSchema. | [
"Returns",
"exclusive",
"groups",
"in",
"the",
"LabelSchema."
] | def get_exclusive_groups(self) -> List[LabelGroup]:
return [group for group in self._groups if group.group_type == LabelGroupType.EXCLUSIVE] | ['def', 'get_exclusive_groups(self)', '->', 'List[LabelGroup]:', 'return', '[group', 'for', 'group', 'in', 'self._groups', 'if', 'group.group_type', '==', 'LabelGroupType.EXCLUSIVE]'] | 918,570 |
openvinotoolkit/training_extensions | label_schema.py | LabelSchemaEntity.add_labels_to_group_by_group_name | add_labels_to_group_by_group_name | Adds `labels` to group named `group_name`. | [
"Adds",
"`labels`",
"to",
"group",
"named",
"`group_name`."
] | def add_labels_to_group_by_group_name(self, group_name: str, labels: Sequence[LabelEntity]):
group = self.get_label_group_by_name(group_name)
if group is not None:
group.labels.extend(labels)
else:
raise LabelGroupDoesNotExistException(f"group with name '{group_name}' does not exist, cannot ... | ['def', 'add_labels_to_group_by_group_name(self,', 'group_name:', 'str,', 'labels:', 'Sequence[LabelEntity]):', 'group', '=', 'self.get_label_group_by_name(group_name)', 'if', 'group', 'is', 'not', 'None:', 'group.labels.extend(labels)', 'else:', 'raise', 'LabelGroupDoesNotExistException(f"group', 'with', 'name', "'{gr... | 918,571 |
openvinotoolkit/training_extensions | label_schema.py | LabelSchemaEntity.are_exclusive | are_exclusive | Returns whether `label` and `label2` are mutually exclusive. | [
"Returns",
"whether",
"`label`",
"and",
"`label2`",
"are",
"mutually",
"exclusive."
] | def are_exclusive(self, label1: LabelEntity, label2: LabelEntity) -> bool:
return label2 in self.get_labels_exclusive_to(label1) | ['def', 'are_exclusive(self,', 'label1:', 'LabelEntity,', 'label2:', 'LabelEntity)', '->', 'bool:', 'return', 'label2', 'in', 'self.get_labels_exclusive_to(label1)'] | 918,572 |
openvinotoolkit/training_extensions | label_schema.py | LabelSchemaEntity.get_children | get_children | Return a list of the children of the passed parent Label. | [
"Return",
"a",
"list",
"of",
"the",
"children",
"of",
"the",
"passed",
"parent",
"Label."
] | def get_children(self, parent: LabelEntity) -> List[LabelEntity]:
parent = self.__get_label(parent)
return self.label_tree.get_children(parent) | ['def', 'get_children(self,', 'parent:', 'LabelEntity)', '->', 'List[LabelEntity]:', 'parent', '=', 'self.__get_label(parent)', 'return', 'self.label_tree.get_children(parent)'] | 918,573 |
openvinotoolkit/training_extensions | label_schema.py | LabelSchemaEntity.get_group_containing_label | get_group_containing_label | Returns the label group which contains the label. | [
"Returns",
"the",
"label",
"group",
"which",
"contains",
"the",
"label."
] | def get_group_containing_label(self, label: LabelEntity) -> Optional[LabelGroup]:
label = self.__get_label(label)
for group in self._groups:
if label in group.labels:
return group
return None | ['def', 'get_group_containing_label(self,', 'label:', 'LabelEntity)', '->', 'Optional[LabelGroup]:', 'label', '=', 'self.__get_label(label)', 'for', 'group', 'in', 'self._groups:', 'if', 'label', 'in', 'group.labels:', 'return', 'group', 'return', 'None'] | 918,577 |
openvinotoolkit/training_extensions | label_schema.py | LabelSchemaEntity.get_labels_exclusive_to | get_labels_exclusive_to | Returns a list of labels that are exclusive to the passed label. | [
"Returns",
"a",
"list",
"of",
"labels",
"that",
"are",
"exclusive",
"to",
"the",
"passed",
"label."
] | def get_labels_exclusive_to(self, label: LabelEntity) -> List[LabelEntity]:
if label.is_empty:
exclusive_labels = self.__get_exclusivity_for_empty_label(label=label)
else:
exclusive_labels = self.__get_exclusivity_recursion(label=label)
return exclusive_labels | ['def', 'get_labels_exclusive_to(self,', 'label:', 'LabelEntity)', '->', 'List[LabelEntity]:', 'if', 'label.is_empty:', 'exclusive_labels', '=', 'self.__get_exclusivity_for_empty_label(label=label)', 'else:', 'exclusive_labels', '=', 'self.__get_exclusivity_recursion(label=label)', 'return', 'exclusive_labels'] | 918,578 |
openvinotoolkit/training_extensions | metadata.py | IMetadata.name | name | Gets or sets the name of the Metadata item. | [
"Gets",
"or",
"sets",
"the",
"name",
"of",
"the",
"Metadata",
"item."
] | def name(self):
return self.__name | ['def', 'name(self):', 'return', 'self.__name'] | 918,587 |
openvinotoolkit/training_extensions | metrics.py | CountMetric.type | type | Returns the type of the MetricEntity. | [
"Returns",
"the",
"type",
"of",
"the",
"MetricEntity."
] | def type():
return 'count' | ['def', 'type():', 'return', "'count'"] | 918,590 |
openvinotoolkit/training_extensions | metrics.py | CurveMetric.ys | ys | Returns the list of floats on y-axis. | [
"Returns",
"the",
"list",
"of",
"floats",
"on",
"y-axis."
] | def ys(self) -> List[float]:
return self.__ys | ['def', 'ys(self)', '->', 'List[float]:', 'return', 'self.__ys'] | 918,597 |
openvinotoolkit/training_extensions | metrics.py | CurveMetric.xs | xs | Returns the list of floats on x-axis. | [
"Returns",
"the",
"list",
"of",
"floats",
"on",
"x-axis."
] | def xs(self) -> List[float]:
return self.__xs | ['def', 'xs(self)', '->', 'List[float]:', 'return', 'self.__xs'] | 918,598 |
openvinotoolkit/training_extensions | metrics.py | MatrixMetric.matrix_values | matrix_values | Returns the matrix data. | [
"Returns",
"the",
"matrix",
"data."
] | def matrix_values(self) -> np.ndarray:
return self.__matrix_values | ['def', 'matrix_values(self)', '->', 'np.ndarray:', 'return', 'self.__matrix_values'] | 918,600 |
openvinotoolkit/training_extensions | metrics.py | MatrixMetric.row_labels | row_labels | Returns the row labels. | [
"Returns",
"the",
"row",
"labels."
] | def row_labels(self) -> Optional[List[str]]:
return self.__row_labels | ['def', 'row_labels(self)', '->', 'Optional[List[str]]:', 'return', 'self.__row_labels'] | 918,601 |
openvinotoolkit/training_extensions | metrics.py | MatrixMetric.normalize | normalize | Normalizes the confusion matrix by dividing by the sum of the rows. | [
"Normalizes",
"the",
"confusion",
"matrix",
"by",
"dividing",
"by",
"the",
"sum",
"of",
"the",
"rows."
] | def normalize(self):
self.__matrix_values = self.__matrix_values.astype(np.float32) / self.__matrix_values.astype(np.float32).sum(axis=1, keepdims=True)
if not np.all(self.__matrix_values.sum(axis=1, keepdims=True) > 0):
self.__matrix_values = np.nan_to_num(self.__matrix_values)
logger = logging... | ['def', 'normalize(self):', 'self.__matrix_values', '=', 'self.__matrix_values.astype(np.float32)', '/', 'self.__matrix_values.astype(np.float32).sum(axis=1,', 'keepdims=True)', 'if', 'not', 'np.all(self.__matrix_values.sum(axis=1,', 'keepdims=True)', '>', '0):', 'self.__matrix_values', '=', 'np.nan_to_num(self.__matri... | 918,603 |
openvinotoolkit/training_extensions | metrics.py | VisualizationInfo.type | type | Returns the type of the visualization. | [
"Returns",
"the",
"type",
"of",
"the",
"visualization."
] | def type(self) -> VisualizationType:
return self.__type | ['def', 'type(self)', '->', 'VisualizationType:', 'return', 'self.__type'] | 918,606 |
openvinotoolkit/training_extensions | metrics.py | MultiScorePerformance.primary_score | primary_score | Return the primary score metric. | [
"Return",
"the",
"primary",
"score",
"metric."
] | def primary_score(self) -> Optional[ScoreMetric]:
return self._primary_score | ['def', 'primary_score(self)', '->', 'Optional[ScoreMetric]:', 'return', 'self._primary_score'] | 918,608 |
openvinotoolkit/training_extensions | model.py | ModelEntity.id_ | id_ | Gets or sets the id of a Model. | [
"Gets",
"or",
"sets",
"the",
"id",
"of",
"a",
"Model."
] | def id_(self) -> ID:
return self.__id_ | ['def', 'id_(self)', '->', 'ID:', 'return', 'self.__id_'] | 918,610 |
openvinotoolkit/training_extensions | model.py | ModelEntity.configuration | configuration | Gets or sets the configuration of the Model. | [
"Gets",
"or",
"sets",
"the",
"configuration",
"of",
"the",
"Model."
] | def configuration(self) -> ModelConfiguration:
return self.__configuration | ['def', 'configuration(self)', '->', 'ModelConfiguration:', 'return', 'self.__configuration'] | 918,611 |
openvinotoolkit/training_extensions | model.py | ModelEntity.creation_date | creation_date | Gets or sets the creation_date of the Model. | [
"Gets",
"or",
"sets",
"the",
"creation_date",
"of",
"the",
"Model."
] | def creation_date(self) -> datetime.datetime:
return self.__creation_date | ['def', 'creation_date(self)', '->', 'datetime.datetime:', 'return', 'self.__creation_date'] | 918,612 |
openvinotoolkit/training_extensions | model.py | ModelEntity.train_dataset | train_dataset | Gets or sets the current Training Dataset. | [
"Gets",
"or",
"sets",
"the",
"current",
"Training",
"Dataset."
] | def train_dataset(self) -> 'DatasetEntity':
return self.__train_dataset | ['def', 'train_dataset(self)', '->', "'DatasetEntity':", 'return', 'self.__train_dataset'] | 918,613 |
openvinotoolkit/training_extensions | model.py | ModelEntity.version | version | Gets or sets the version. | [
"Gets",
"or",
"sets",
"the",
"version."
] | def version(self) -> int:
return self.__version | ['def', 'version(self)', '->', 'int:', 'return', 'self.__version'] | 918,616 |
openvinotoolkit/training_extensions | model.py | ModelEntity.tags | tags | Gets or sets the tags of the Model. | [
"Gets",
"or",
"sets",
"the",
"tags",
"of",
"the",
"Model."
] | def tags(self) -> List[str]:
return self.__tags | ['def', 'tags(self)', '->', 'List[str]:', 'return', 'self.__tags'] | 918,617 |
openvinotoolkit/training_extensions | model.py | ModelEntity.performance | performance | Gets or sets the current Performance of the Model. | [
"Gets",
"or",
"sets",
"the",
"current",
"Performance",
"of",
"the",
"Model."
] | def performance(self) -> Performance:
return self.__performance | ['def', 'performance(self)', '->', 'Performance:', 'return', 'self.__performance'] | 918,619 |
openvinotoolkit/training_extensions | model.py | ModelEntity.target_device | target_device | Get or set the device on which the model will be deployed. | [
"Get",
"or",
"set",
"the",
"device",
"on",
"which",
"the",
"model",
"will",
"be",
"deployed."
] | def target_device(self) -> TargetDevice:
return self.__target_device | ['def', 'target_device(self)', '->', 'TargetDevice:', 'return', 'self.__target_device'] | 918,624 |
openvinotoolkit/training_extensions | model.py | ModelEntity.target_device_type | target_device_type | Get or set the type of the target device used by the model. | [
"Get",
"or",
"set",
"the",
"type",
"of",
"the",
"target",
"device",
"used",
"by",
"the",
"model."
] | def target_device_type(self) -> Optional[str]:
return self.__target_device_type | ['def', 'target_device_type(self)', '->', 'Optional[str]:', 'return', 'self.__target_device_type'] | 918,625 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.