code-loader 1.0.151a2__tar.gz → 1.0.151.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/PKG-INFO +1 -1
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/contract/datasetclasses.py +0 -1
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/inner_leap_binder/leapbinder.py +13 -18
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/inner_leap_binder/leapbinder_decorators.py +2 -6
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/leaploader.py +13 -2
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/leaploaderbase.py +7 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/pyproject.toml +1 -1
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/LICENSE +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/README.md +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/__init__.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/mixpanel_tracker.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/plot_functions/plot_functions.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/utils.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/visualizers/default_visualizers.py +0 -0
{code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/inner_leap_binder/leapbinder.py
RENAMED
|
@@ -24,6 +24,7 @@ from code_loader.visualizers.default_visualizers import DefaultVisualizer, \
|
|
|
24
24
|
default_image_visualizer, default_horizontal_bar_visualizer, default_word_visualizer, \
|
|
25
25
|
default_image_mask_visualizer, default_text_mask_visualizer, default_raw_data_visualizer, default_video_visualizer
|
|
26
26
|
|
|
27
|
+
|
|
27
28
|
mapping_runtime_mode_env_var_mame = '__MAPPING_RUNTIME_MODE__'
|
|
28
29
|
|
|
29
30
|
|
|
@@ -238,6 +239,7 @@ class LeapBinder:
|
|
|
238
239
|
|
|
239
240
|
self._encoder_names.append(name)
|
|
240
241
|
|
|
242
|
+
|
|
241
243
|
def set_instance_masks(self, function: InstanceCallableInterface, name: str) -> None:
|
|
242
244
|
"""
|
|
243
245
|
Set the instance mask handler function.
|
|
@@ -252,6 +254,7 @@ class LeapBinder:
|
|
|
252
254
|
function = to_numpy_return_masks_wrapper(function)
|
|
253
255
|
self.setup_container.instance_masks.append(ElementInstanceMasksHandler(name, function))
|
|
254
256
|
|
|
257
|
+
|
|
255
258
|
def add_custom_loss(self, function: CustomCallableInterface, name: str) -> None:
|
|
256
259
|
"""
|
|
257
260
|
Add a custom loss function to the setup.
|
|
@@ -265,7 +268,7 @@ class LeapBinder:
|
|
|
265
268
|
- A numeric value representing the loss.
|
|
266
269
|
name (str): The name of the custom loss function.
|
|
267
270
|
|
|
268
|
-
Example:
|
|
271
|
+
Example:get_metadata
|
|
269
272
|
def custom_loss_function(y_true, y_pred):
|
|
270
273
|
# Calculate mean squared error as custom loss
|
|
271
274
|
return np.mean(np.square(y_true - y_pred))
|
|
@@ -328,8 +331,7 @@ class LeapBinder:
|
|
|
328
331
|
metric_handler_data = MetricHandlerData(name, regular_arg_names, direction, compute_insights)
|
|
329
332
|
self.setup_container.metrics.append(MetricHandler(metric_handler_data, function))
|
|
330
333
|
|
|
331
|
-
def add_prediction(self, name: str, labels: List[str], channel_dim: int = -1,
|
|
332
|
-
prediction_index: Optional[int] = None) -> None:
|
|
334
|
+
def add_prediction(self, name: str, labels: List[str], channel_dim: int = -1, prediction_index: Optional[int]=None) -> None:
|
|
333
335
|
"""
|
|
334
336
|
Add prediction labels to the setup.
|
|
335
337
|
|
|
@@ -346,8 +348,7 @@ class LeapBinder:
|
|
|
346
348
|
self.setup_container.prediction_types.append(PredictionTypeHandler(name, labels, channel_dim))
|
|
347
349
|
if prediction_index is not None:
|
|
348
350
|
node_connection = NodeConnection(NodeMapping(name, NodeMappingType.PredictionLabels),
|
|
349
|
-
{'temp': NodeMapping('',
|
|
350
|
-
NodeMappingType(f'Prediction{prediction_index}'))})
|
|
351
|
+
{'temp': NodeMapping('', NodeMappingType(f'Prediction{prediction_index}'))})
|
|
351
352
|
|
|
352
353
|
self.mapping_connections.append(node_connection)
|
|
353
354
|
|
|
@@ -383,8 +384,7 @@ class LeapBinder:
|
|
|
383
384
|
self._encoder_names.append(name)
|
|
384
385
|
|
|
385
386
|
def set_metadata(self, function: MetadataSectionCallableInterface, name: str,
|
|
386
|
-
metadata_type: Optional[Union[DatasetMetadataType, Dict[str, DatasetMetadataType]]] = None
|
|
387
|
-
use_for_semantic_ls: Optional[bool] = None) -> None:
|
|
387
|
+
metadata_type: Optional[Union[DatasetMetadataType, Dict[str, DatasetMetadataType]]] = None) -> None:
|
|
388
388
|
"""
|
|
389
389
|
Set the metadata handler function. This function is used for measuring and analyzing external variable values per sample, which is recommended for analysis within the Tensorleap platform.
|
|
390
390
|
|
|
@@ -419,7 +419,7 @@ class LeapBinder:
|
|
|
419
419
|
leap_binder.set_metadata(metadata_handler_index, name='metadata_index')
|
|
420
420
|
leap_binder.set_metadata(metadata_handler_image_mean, name='metadata_image_mean')
|
|
421
421
|
"""
|
|
422
|
-
self.setup_container.metadata.append(MetadataHandler(name, function, metadata_type
|
|
422
|
+
self.setup_container.metadata.append(MetadataHandler(name, function, metadata_type))
|
|
423
423
|
|
|
424
424
|
def set_custom_latent_space(self, function: SectionCallableInterface) -> None:
|
|
425
425
|
"""
|
|
@@ -534,8 +534,7 @@ class LeapBinder:
|
|
|
534
534
|
@staticmethod
|
|
535
535
|
def check_handler(
|
|
536
536
|
preprocess_response: PreprocessResponse, test_result: List[DatasetTestResultPayload],
|
|
537
|
-
dataset_base_handler: Union[DatasetBaseHandler, MetadataHandler], state: DataStateEnum) -> List[
|
|
538
|
-
DatasetTestResultPayload]:
|
|
537
|
+
dataset_base_handler: Union[DatasetBaseHandler, MetadataHandler], state: DataStateEnum) -> List[DatasetTestResultPayload]:
|
|
539
538
|
assert preprocess_response.sample_ids is not None
|
|
540
539
|
raw_result = dataset_base_handler.function(preprocess_response.sample_ids[0], preprocess_response)
|
|
541
540
|
handler_type = 'metadata' if isinstance(dataset_base_handler, MetadataHandler) else None
|
|
@@ -555,8 +554,7 @@ class LeapBinder:
|
|
|
555
554
|
|
|
556
555
|
metadata_type = None
|
|
557
556
|
if single_metadata_result is None:
|
|
558
|
-
if state != DataStateEnum.training and test_result[
|
|
559
|
-
i].name == f'{dataset_base_handler.name}_{single_metadata_name}':
|
|
557
|
+
if state != DataStateEnum.training and test_result[i].name == f'{dataset_base_handler.name}_{single_metadata_name}':
|
|
560
558
|
metadata_test_result_payloads[i] = test_result[i]
|
|
561
559
|
continue
|
|
562
560
|
|
|
@@ -564,8 +562,7 @@ class LeapBinder:
|
|
|
564
562
|
raise Exception(f"Metadata {single_metadata_name} is None and no metadata type is provided")
|
|
565
563
|
elif isinstance(dataset_base_handler.metadata_type, dict):
|
|
566
564
|
if single_metadata_name not in dataset_base_handler.metadata_type:
|
|
567
|
-
raise Exception(
|
|
568
|
-
f"Metadata {single_metadata_name} is None and no metadata type is provided")
|
|
565
|
+
raise Exception(f"Metadata {single_metadata_name} is None and no metadata type is provided")
|
|
569
566
|
metadata_type = dataset_base_handler.metadata_type[single_metadata_name]
|
|
570
567
|
else:
|
|
571
568
|
raise Exception(f"Metadata {single_metadata_name} is None and metadata type is not a dict")
|
|
@@ -582,11 +579,9 @@ class LeapBinder:
|
|
|
582
579
|
return test_result
|
|
583
580
|
|
|
584
581
|
if dataset_base_handler.metadata_type is None:
|
|
585
|
-
raise Exception(
|
|
586
|
-
f"Metadata {dataset_base_handler.name} is None and no metadata type is provided")
|
|
582
|
+
raise Exception(f"Metadata {dataset_base_handler.name} is None and no metadata type is provided")
|
|
587
583
|
elif isinstance(dataset_base_handler.metadata_type, dict):
|
|
588
|
-
raise Exception(
|
|
589
|
-
f"Metadata {dataset_base_handler.name} is None and no metadata type is provided")
|
|
584
|
+
raise Exception(f"Metadata {dataset_base_handler.name} is None and no metadata type is provided")
|
|
590
585
|
metadata_type = dataset_base_handler.metadata_type
|
|
591
586
|
|
|
592
587
|
result_shape = get_shape(raw_result)
|
|
@@ -799,17 +799,13 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
|
799
799
|
|
|
800
800
|
|
|
801
801
|
def tensorleap_metadata(
|
|
802
|
-
name: str, metadata_type: Optional[Union[DatasetMetadataType, Dict[str, DatasetMetadataType]]] = None
|
|
803
|
-
use_for_semantic_ls: Optional[bool] = None):
|
|
802
|
+
name: str, metadata_type: Optional[Union[DatasetMetadataType, Dict[str, DatasetMetadataType]]] = None):
|
|
804
803
|
def decorating_function(user_function: MetadataSectionCallableInterface):
|
|
805
804
|
for metadata_handler in leap_binder.setup_container.metadata:
|
|
806
805
|
if metadata_handler.name == name:
|
|
807
806
|
raise Exception(f'Metadata with name {name} already exists. '
|
|
808
807
|
f'Please choose another')
|
|
809
808
|
|
|
810
|
-
if not type(use_for_semantic_ls) in (type(None), bool):
|
|
811
|
-
raise Exception(f'use_for_semantic_ls must be either None or a boolean')
|
|
812
|
-
|
|
813
809
|
def _validate_input_args(sample_id: Union[int, str], preprocess_response: PreprocessResponse):
|
|
814
810
|
assert type(sample_id) == preprocess_response.sample_id_type, \
|
|
815
811
|
(f'{user_function.__name__}() validation failed: '
|
|
@@ -845,7 +841,7 @@ def tensorleap_metadata(
|
|
|
845
841
|
|
|
846
842
|
return result
|
|
847
843
|
|
|
848
|
-
leap_binder.set_metadata(inner_without_validate, name, metadata_type
|
|
844
|
+
leap_binder.set_metadata(inner_without_validate, name, metadata_type)
|
|
849
845
|
|
|
850
846
|
def inner(*args, **kwargs):
|
|
851
847
|
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
|
@@ -163,7 +163,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
163
163
|
if state == DataStateEnum.unlabeled and sample_id not in preprocess_result[state].sample_ids:
|
|
164
164
|
self._preprocess_result(update_unlabeled_preprocess=True)
|
|
165
165
|
|
|
166
|
-
metadata, metadata_is_none = self.
|
|
166
|
+
metadata, metadata_is_none = self.get_metadata(state, sample_id)
|
|
167
167
|
|
|
168
168
|
custom_latent_space = None
|
|
169
169
|
if global_leap_binder.setup_container.custom_latent_space is not None:
|
|
@@ -521,13 +521,24 @@ class LeapLoader(LeapLoaderBase):
|
|
|
521
521
|
|
|
522
522
|
return converted_value, is_none
|
|
523
523
|
|
|
524
|
-
def
|
|
524
|
+
def get_metadata(self, state: DataStateEnum, sample_id: Union[int, str], only_metadata_names: Optional[List[str]] = None) -> Tuple[
|
|
525
525
|
Dict[str, Union[str, int, bool, float]], Dict[str, bool]]:
|
|
526
|
+
|
|
527
|
+
def is_metadata_name_starts_with_handler_name(_handler):
|
|
528
|
+
for metadata_name in only_metadata_names:
|
|
529
|
+
if metadata_name.startswith(_handler.name + '_') or metadata_name == _handler.name:
|
|
530
|
+
return True
|
|
531
|
+
return False
|
|
532
|
+
|
|
526
533
|
result_agg = {}
|
|
527
534
|
is_none = {}
|
|
528
535
|
preprocess_result = self._preprocess_result()
|
|
529
536
|
preprocess_state = preprocess_result[state]
|
|
530
537
|
for handler in global_leap_binder.setup_container.metadata:
|
|
538
|
+
if only_metadata_names:
|
|
539
|
+
if not is_metadata_name_starts_with_handler_name(handler):
|
|
540
|
+
continue
|
|
541
|
+
|
|
531
542
|
handler_result = handler.function(sample_id, preprocess_state)
|
|
532
543
|
if isinstance(handler_result, dict):
|
|
533
544
|
for single_metadata_name, single_metadata_result in handler_result.items():
|
|
@@ -87,6 +87,13 @@ class LeapLoaderBase:
|
|
|
87
87
|
input_tensors_by_arg_name: Dict[str, npt.NDArray[np.float32]]):
|
|
88
88
|
pass
|
|
89
89
|
|
|
90
|
+
@abstractmethod
|
|
91
|
+
def get_metadata(
|
|
92
|
+
self, state: DataStateEnum, sample_id: Union[int, str],
|
|
93
|
+
only_metadata_names: Optional[List[str]] = None
|
|
94
|
+
) -> Tuple[Dict[str, Union[str, int, bool, float]], Dict[str, bool]]:
|
|
95
|
+
pass
|
|
96
|
+
|
|
90
97
|
@abstractmethod
|
|
91
98
|
def run_heatmap_visualizer(self, visualizer_name: str, sample_ids: np.array, state: DataStateEnum,
|
|
92
99
|
input_tensors_by_arg_name: Dict[str, npt.NDArray[np.float32]]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/contract/responsedataclasses.py
RENAMED
|
File without changes
|
{code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/contract/visualizer_classes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/cli_config_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/experiment_api/experiment_context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/inner_leap_binder/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/plot_functions/plot_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.151a2 → code_loader-1.0.151.dev2}/code_loader/visualizers/default_visualizers.py
RENAMED
|
File without changes
|