code-loader 1.0.89__tar.gz → 1.0.90__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.89 → code_loader-1.0.90}/PKG-INFO +1 -1
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/contract/responsedataclasses.py +0 -8
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/inner_leap_binder/leapbinder.py +1 -9
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/inner_leap_binder/leapbinder_decorators.py +4 -39
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/leaploader.py +2 -4
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/visualizers/default_visualizers.py +9 -4
- {code_loader-1.0.89 → code_loader-1.0.90}/pyproject.toml +1 -1
- code_loader-1.0.89/code_loader/contract/mapping.py +0 -56
- {code_loader-1.0.89 → code_loader-1.0.90}/LICENSE +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/README.md +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/__init__.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/contract/datasetclasses.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/leaploaderbase.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/utils.py +0 -0
- {code_loader-1.0.89 → code_loader-1.0.90}/code_loader/visualizers/__init__.py +0 -0
@@ -2,7 +2,6 @@ from typing import List, Optional, Dict, Any, Union
|
|
2
2
|
|
3
3
|
from dataclasses import dataclass, field
|
4
4
|
from code_loader.contract.enums import DatasetMetadataType, LeapDataType
|
5
|
-
from code_loader.contract.mapping import NodeConnection
|
6
5
|
|
7
6
|
|
8
7
|
@dataclass
|
@@ -121,12 +120,6 @@ class BoundingBox:
|
|
121
120
|
metadata: Optional[Dict[str, Union[str, int, float]]] = None
|
122
121
|
|
123
122
|
|
124
|
-
|
125
|
-
@dataclass
|
126
|
-
class EngineFileContract:
|
127
|
-
node_connections: Optional[List[NodeConnection]] = None
|
128
|
-
|
129
|
-
|
130
123
|
@dataclass
|
131
124
|
class DatasetIntegParseResult:
|
132
125
|
payloads: List[DatasetTestResultPayload]
|
@@ -136,4 +129,3 @@ class DatasetIntegParseResult:
|
|
136
129
|
model_setup: Optional[ModelSetup] = None
|
137
130
|
general_error: Optional[str] = None
|
138
131
|
print_log: Optional[str] = None
|
139
|
-
engine_file_contract: Optional[EngineFileContract] = None
|
@@ -12,7 +12,6 @@ from code_loader.contract.datasetclasses import SectionCallableInterface, InputH
|
|
12
12
|
CustomMultipleReturnCallableInterfaceMultiArgs, DatasetBaseHandler, custom_latent_space_attribute, \
|
13
13
|
RawInputsForHeatmap, VisualizerHandlerData, MetricHandlerData, CustomLossHandlerData, SamplePreprocessResponse
|
14
14
|
from code_loader.contract.enums import LeapDataType, DataStateEnum, DataStateType, MetricDirection, DatasetMetadataType
|
15
|
-
from code_loader.contract.mapping import NodeConnection, NodeMapping, NodeMappingType
|
16
15
|
from code_loader.contract.responsedataclasses import DatasetTestResultPayload
|
17
16
|
from code_loader.contract.visualizer_classes import map_leap_data_type_to_visualizer_class
|
18
17
|
from code_loader.default_losses import loss_name_to_function
|
@@ -44,8 +43,6 @@ class LeapBinder:
|
|
44
43
|
self._extend_with_default_metrics()
|
45
44
|
self._extend_with_default_losses()
|
46
45
|
|
47
|
-
self.mapping_connections: List[NodeConnection] = []
|
48
|
-
|
49
46
|
self.batch_size_to_validate: Optional[int] = None
|
50
47
|
|
51
48
|
def _extend_with_default_visualizers(self) -> None:
|
@@ -310,7 +307,7 @@ class LeapBinder:
|
|
310
307
|
metric_handler_data = MetricHandlerData(name, regular_arg_names, direction, compute_insights)
|
311
308
|
self.setup_container.metrics.append(MetricHandler(metric_handler_data, function))
|
312
309
|
|
313
|
-
def add_prediction(self, name: str, labels: List[str], channel_dim: int = -1
|
310
|
+
def add_prediction(self, name: str, labels: List[str], channel_dim: int = -1) -> None:
|
314
311
|
"""
|
315
312
|
Add prediction labels to the setup.
|
316
313
|
|
@@ -325,11 +322,6 @@ class LeapBinder:
|
|
325
322
|
leap_binder.add_prediction(name='class_labels', labels=['cat', 'dog'])
|
326
323
|
"""
|
327
324
|
self.setup_container.prediction_types.append(PredictionTypeHandler(name, labels, channel_dim))
|
328
|
-
if prediction_index is not None:
|
329
|
-
node_connection = NodeConnection(NodeMapping(name, NodeMappingType.PredictionLabels),
|
330
|
-
{'temp': NodeMapping('', NodeMappingType(f'Prediction{prediction_index}'))})
|
331
|
-
|
332
|
-
self.mapping_connections.append(node_connection)
|
333
325
|
|
334
326
|
def set_ground_truth(self, function: SectionCallableInterface, name: str) -> None:
|
335
327
|
"""
|
{code_loader-1.0.89 → code_loader-1.0.90}/code_loader/inner_leap_binder/leapbinder_decorators.py
RENAMED
@@ -11,25 +11,13 @@ from code_loader.contract.datasetclasses import CustomCallableInterfaceMultiArgs
|
|
11
11
|
ConfusionMatrixElement, SamplePreprocessResponse
|
12
12
|
from code_loader.contract.enums import MetricDirection, LeapDataType, DatasetMetadataType
|
13
13
|
from code_loader import leap_binder
|
14
|
-
from code_loader.contract.mapping import NodeMapping, NodeMappingType, NodeConnection
|
15
14
|
from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, LeapTextMask, LeapText, LeapGraph, \
|
16
15
|
LeapHorizontalBar, LeapImageWithBBox, LeapImageWithHeatmap
|
17
16
|
|
18
17
|
|
19
|
-
def _add_mapping_connections(connects_to, arg_names, node_mapping_type, name):
|
20
|
-
for user_unique_name, connection_destinations in connects_to.items():
|
21
|
-
main_node_mapping = NodeMapping(name, node_mapping_type, user_unique_name, arg_names=arg_names)
|
22
|
-
node_inputs = {}
|
23
|
-
for arg_name, destination in zip(arg_names, connection_destinations):
|
24
|
-
node_inputs[arg_name] = destination.node_mapping
|
25
|
-
|
26
|
-
leap_binder.mapping_connections.append(NodeConnection(main_node_mapping, node_inputs))
|
27
|
-
|
28
|
-
|
29
18
|
def tensorleap_custom_metric(name: str,
|
30
19
|
direction: Union[MetricDirection, Dict[str, MetricDirection]] = MetricDirection.Downward,
|
31
|
-
compute_insights: Optional[Union[bool, Dict[str, bool]]] = None
|
32
|
-
connects_to=None):
|
20
|
+
compute_insights: Optional[Union[bool, Dict[str, bool]]] = None):
|
33
21
|
def decorating_function(user_function: Union[CustomCallableInterfaceMultiArgs,
|
34
22
|
CustomMultipleReturnCallableInterfaceMultiArgs,
|
35
23
|
ConfusionMatrixCallableInterfaceMultiArgs]):
|
@@ -40,10 +28,6 @@ def tensorleap_custom_metric(name: str,
|
|
40
28
|
|
41
29
|
leap_binder.add_custom_metric(user_function, name, direction, compute_insights)
|
42
30
|
|
43
|
-
if connects_to is not None:
|
44
|
-
arg_names = leap_binder.setup_container.metrics[-1].metric_handler_data.arg_names
|
45
|
-
_add_mapping_connections(connects_to, arg_names, NodeMappingType.Metric, name)
|
46
|
-
|
47
31
|
def _validate_input_args(*args, **kwargs) -> None:
|
48
32
|
for i, arg in enumerate(args):
|
49
33
|
assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (
|
@@ -132,8 +116,7 @@ def tensorleap_custom_metric(name: str,
|
|
132
116
|
|
133
117
|
|
134
118
|
def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
135
|
-
heatmap_function: Optional[Callable[..., npt.NDArray[np.float32]]] = None
|
136
|
-
connects_to=None):
|
119
|
+
heatmap_function: Optional[Callable[..., npt.NDArray[np.float32]]] = None):
|
137
120
|
def decorating_function(user_function: VisualizerCallableInterface):
|
138
121
|
for viz_handler in leap_binder.setup_container.visualizers:
|
139
122
|
if viz_handler.visualizer_handler_data.name == name:
|
@@ -142,10 +125,6 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
142
125
|
|
143
126
|
leap_binder.set_visualizer(user_function, name, visualizer_type, heatmap_function)
|
144
127
|
|
145
|
-
if connects_to is not None:
|
146
|
-
arg_names = leap_binder.setup_container.visualizers[-1].visualizer_handler_data.arg_names
|
147
|
-
_add_mapping_connections(connects_to, arg_names, NodeMappingType.Visualizer, name)
|
148
|
-
|
149
128
|
def _validate_input_args(*args, **kwargs):
|
150
129
|
for i, arg in enumerate(args):
|
151
130
|
assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (
|
@@ -296,7 +275,7 @@ def tensorleap_unlabeled_preprocess():
|
|
296
275
|
return decorating_function
|
297
276
|
|
298
277
|
|
299
|
-
def tensorleap_input_encoder(name: str, channel_dim=-1
|
278
|
+
def tensorleap_input_encoder(name: str, channel_dim=-1):
|
300
279
|
def decorating_function(user_function: SectionCallableInterface):
|
301
280
|
for input_handler in leap_binder.setup_container.inputs:
|
302
281
|
if input_handler.name == name:
|
@@ -335,11 +314,6 @@ def tensorleap_input_encoder(name: str, channel_dim=-1, model_input_index=None):
|
|
335
314
|
_validate_result(result)
|
336
315
|
return result
|
337
316
|
|
338
|
-
node_mapping_type = NodeMappingType.Input
|
339
|
-
if model_input_index is not None:
|
340
|
-
node_mapping_type = NodeMappingType(f'Input{str(model_input_index)}')
|
341
|
-
inner.node_mapping = NodeMapping(name, node_mapping_type)
|
342
|
-
|
343
317
|
return inner
|
344
318
|
|
345
319
|
return decorating_function
|
@@ -380,16 +354,12 @@ def tensorleap_gt_encoder(name: str):
|
|
380
354
|
_validate_result(result)
|
381
355
|
return result
|
382
356
|
|
383
|
-
inner.node_mapping = NodeMapping(name, NodeMappingType.GroundTruth)
|
384
|
-
|
385
357
|
return inner
|
386
358
|
|
387
|
-
|
388
|
-
|
389
359
|
return decorating_function
|
390
360
|
|
391
361
|
|
392
|
-
def tensorleap_custom_loss(name: str
|
362
|
+
def tensorleap_custom_loss(name: str):
|
393
363
|
def decorating_function(user_function: CustomCallableInterface):
|
394
364
|
for loss_handler in leap_binder.setup_container.custom_loss_handlers:
|
395
365
|
if loss_handler.custom_loss_handler_data.name == name:
|
@@ -398,11 +368,6 @@ def tensorleap_custom_loss(name: str, connects_to=None):
|
|
398
368
|
|
399
369
|
leap_binder.add_custom_loss(user_function, name)
|
400
370
|
|
401
|
-
if connects_to is not None:
|
402
|
-
arg_names = leap_binder.setup_container.custom_loss_handlers[-1].custom_loss_handler_data.arg_names
|
403
|
-
_add_mapping_connections(connects_to, arg_names, NodeMappingType.CustomLoss, name)
|
404
|
-
|
405
|
-
|
406
371
|
valid_types = (np.ndarray, SamplePreprocessResponse)
|
407
372
|
try:
|
408
373
|
import tensorflow as tf
|
@@ -19,8 +19,7 @@ from code_loader.contract.enums import DataStateEnum, TestingSectionEnum, DataSt
|
|
19
19
|
from code_loader.contract.exceptions import DatasetScriptException
|
20
20
|
from code_loader.contract.responsedataclasses import DatasetIntegParseResult, DatasetTestResultPayload, \
|
21
21
|
DatasetPreprocess, DatasetSetup, DatasetInputInstance, DatasetOutputInstance, DatasetMetadataInstance, \
|
22
|
-
VisualizerInstance, PredictionTypeInstance, ModelSetup, CustomLayerInstance, MetricInstance, CustomLossInstance
|
23
|
-
EngineFileContract
|
22
|
+
VisualizerInstance, PredictionTypeInstance, ModelSetup, CustomLayerInstance, MetricInstance, CustomLossInstance
|
24
23
|
from code_loader.inner_leap_binder import global_leap_binder
|
25
24
|
from code_loader.leaploaderbase import LeapLoaderBase
|
26
25
|
from code_loader.utils import get_root_exception_file_and_line_number
|
@@ -180,8 +179,7 @@ class LeapLoader(LeapLoaderBase):
|
|
180
179
|
return DatasetIntegParseResult(is_valid=is_valid, payloads=test_payloads,
|
181
180
|
is_valid_for_model=is_valid_for_model, setup=setup_response,
|
182
181
|
model_setup=model_setup, general_error=general_error,
|
183
|
-
print_log=print_log
|
184
|
-
engine_file_contract=EngineFileContract(global_leap_binder.mapping_connections))
|
182
|
+
print_log=print_log)
|
185
183
|
|
186
184
|
def _check_preprocess(self) -> DatasetTestResultPayload:
|
187
185
|
test_result = DatasetTestResultPayload('preprocess')
|
@@ -20,21 +20,21 @@ class DefaultVisualizer(Enum):
|
|
20
20
|
|
21
21
|
|
22
22
|
def default_image_visualizer(data: npt.NDArray[np.float32]) -> LeapImage:
|
23
|
-
rescaled_data = rescale_min_max(data)
|
23
|
+
rescaled_data = rescale_min_max(data[0])
|
24
24
|
return LeapImage(rescaled_data)
|
25
25
|
|
26
26
|
|
27
27
|
def default_video_visualizer(data: npt.NDArray[np.float32]) -> LeapVideo:
|
28
|
-
return LeapVideo(data)
|
28
|
+
return LeapVideo(data[0])
|
29
29
|
|
30
30
|
|
31
31
|
def default_graph_visualizer(data: npt.NDArray[np.float32]) -> LeapGraph:
|
32
|
-
return LeapGraph(data)
|
32
|
+
return LeapGraph(data[0])
|
33
33
|
|
34
34
|
|
35
35
|
def default_horizontal_bar_visualizer(data: npt.NDArray[np.float32]) -> LeapHorizontalBar:
|
36
36
|
labels = [str(index) for index in range(data.shape[-1])]
|
37
|
-
return LeapHorizontalBar(data, labels)
|
37
|
+
return LeapHorizontalBar(data[0], labels)
|
38
38
|
|
39
39
|
|
40
40
|
def default_word_visualizer(data: npt.NDArray[np.float32]) -> LeapText:
|
@@ -51,6 +51,11 @@ def default_raw_data_visualizer(data: npt.NDArray[np.float32]) -> LeapText:
|
|
51
51
|
|
52
52
|
|
53
53
|
def default_image_mask_visualizer(mask: npt.NDArray[np.float32], image: npt.NDArray[np.float32]) -> LeapImageMask:
|
54
|
+
if image.shape[0] == 1:
|
55
|
+
image = image[0]
|
56
|
+
if mask.shape[0] == 1:
|
57
|
+
mask = mask[0]
|
58
|
+
|
54
59
|
n_different_labels = mask.shape[-1]
|
55
60
|
labels = [str(i) for i in range(n_different_labels)]
|
56
61
|
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# mypy: ignore-errors
|
2
|
-
|
3
|
-
|
4
|
-
from enum import Enum
|
5
|
-
|
6
|
-
from typing import Optional, Dict, Any, List
|
7
|
-
from dataclasses import dataclass
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
class NodeMappingType(Enum):
|
12
|
-
Visualizer = 'Visualizer'
|
13
|
-
Metric = 'Metric'
|
14
|
-
GroundTruth = 'GroundTruth'
|
15
|
-
Input = 'Input'
|
16
|
-
Layer = 'Layer'
|
17
|
-
Loss = 'Loss'
|
18
|
-
CustomLoss = 'CustomLoss'
|
19
|
-
Optimizer = 'Optimizer'
|
20
|
-
Prediction0 = 'Prediction0'
|
21
|
-
Prediction1 = 'Prediction1'
|
22
|
-
Prediction2 = 'Prediction2'
|
23
|
-
Prediction3 = 'Prediction3'
|
24
|
-
Input0 = 'Input0'
|
25
|
-
Input1 = 'Input1'
|
26
|
-
Input2 = 'Input2'
|
27
|
-
Input3 = 'Input3'
|
28
|
-
Input4 = 'Input4'
|
29
|
-
Input5 = 'Input5'
|
30
|
-
PredictionLabels = 'PredictionLabels'
|
31
|
-
|
32
|
-
|
33
|
-
@dataclass
|
34
|
-
class NodeMapping:
|
35
|
-
name: str
|
36
|
-
type: NodeMappingType
|
37
|
-
user_unique_name: Optional[str] = None
|
38
|
-
sub_type: Optional[str] = None
|
39
|
-
arg_names: Optional[List[str]] = None
|
40
|
-
|
41
|
-
|
42
|
-
@dataclass
|
43
|
-
class NodeConnection:
|
44
|
-
node: NodeMapping
|
45
|
-
node_inputs: Optional[Dict[str, NodeMapping]]
|
46
|
-
|
47
|
-
|
48
|
-
def leap_output(idx):
|
49
|
-
def dummy():
|
50
|
-
return None
|
51
|
-
|
52
|
-
node_mapping_type = NodeMappingType(f'Prediction{str(idx)}')
|
53
|
-
dummy.node_mapping = NodeMapping('', node_mapping_type)
|
54
|
-
|
55
|
-
return dummy
|
56
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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.89 → code_loader-1.0.90}/code_loader/experiment_api/workingspace_config_utils.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|