code-loader 1.0.52__py3-none-any.whl → 1.0.53__py3-none-any.whl
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/inner_leap_binder/leapbinder_decorators.py +9 -9
- code_loader/visualizers/default_visualizers.py +23 -0
- {code_loader-1.0.52.dist-info → code_loader-1.0.53.dist-info}/METADATA +1 -1
- {code_loader-1.0.52.dist-info → code_loader-1.0.53.dist-info}/RECORD +6 -6
- {code_loader-1.0.52.dist-info → code_loader-1.0.53.dist-info}/LICENSE +0 -0
- {code_loader-1.0.52.dist-info → code_loader-1.0.53.dist-info}/WHEEL +0 -0
@@ -93,7 +93,7 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
93
93
|
assert isinstance(arg, np.ndarray), (f'tensorleap_custom_visualizer validation failed: '
|
94
94
|
f'Argument #{i} should be a numpy array. Got {type(arg)}.')
|
95
95
|
if leap_binder.batch_size_to_validate:
|
96
|
-
assert arg.shape[0] ==
|
96
|
+
assert arg.shape[0] == 1, \
|
97
97
|
(f'tensorleap_custom_visualizer validation failed: Argument #{i} '
|
98
98
|
f'first dim should be 1. The visualizers will always run with batch size 1. Got {arg.shape[0]}')
|
99
99
|
|
@@ -101,7 +101,7 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
101
101
|
assert isinstance(arg, np.ndarray), (f'tensorleap_custom_visualizer validation failed: '
|
102
102
|
f'Argument {_arg_name} should be a numpy array. Got {type(arg)}.')
|
103
103
|
if leap_binder.batch_size_to_validate:
|
104
|
-
assert arg.shape[0] ==
|
104
|
+
assert arg.shape[0] == 1, \
|
105
105
|
(f'tensorleap_custom_visualizer validation failed: Argument {_arg_name} '
|
106
106
|
f'first dim should be 1. The visualizers will always run with batch size 1. Got {arg.shape[0]}')
|
107
107
|
|
@@ -279,7 +279,7 @@ def tensorleap_gt_encoder(name: str):
|
|
279
279
|
def decorating_function(user_function: SectionCallableInterface):
|
280
280
|
for gt_handler in leap_binder.setup_container.ground_truths:
|
281
281
|
if gt_handler.name == name:
|
282
|
-
raise Exception(f'
|
282
|
+
raise Exception(f'GT with name {name} already exists. '
|
283
283
|
f'Please choose another')
|
284
284
|
|
285
285
|
leap_binder.set_ground_truth(user_function, name)
|
@@ -319,7 +319,7 @@ def tensorleap_custom_loss(name: str):
|
|
319
319
|
def decorating_function(user_function: CustomCallableInterface):
|
320
320
|
for loss_handler in leap_binder.setup_container.custom_loss_handlers:
|
321
321
|
if loss_handler.name == name:
|
322
|
-
raise Exception(f'
|
322
|
+
raise Exception(f'Custom loss with name {name} already exists. '
|
323
323
|
f'Please choose another')
|
324
324
|
|
325
325
|
leap_binder.add_custom_loss(user_function, name)
|
@@ -327,8 +327,8 @@ def tensorleap_custom_loss(name: str):
|
|
327
327
|
def _validate_input_args(*args, **kwargs):
|
328
328
|
try:
|
329
329
|
import tensorflow as tf
|
330
|
-
except ImportError:
|
331
|
-
raise Exception('the input arguments of the custom loss function should be tensorflow tensors')
|
330
|
+
except ImportError as e:
|
331
|
+
raise Exception('the input arguments of the custom loss function should be tensorflow tensors') from e
|
332
332
|
|
333
333
|
for i, arg in enumerate(args):
|
334
334
|
assert isinstance(arg, tf.Tensor), (f'tensorleap_custom_loss validation failed: '
|
@@ -367,11 +367,11 @@ def tensorleap_custom_layer(name: str):
|
|
367
367
|
|
368
368
|
try:
|
369
369
|
import tensorflow as tf
|
370
|
-
except ImportError:
|
371
|
-
raise Exception('
|
370
|
+
except ImportError as e:
|
371
|
+
raise Exception('Custom layer should be inherit from tf.keras.layers.Layer') from e
|
372
372
|
|
373
373
|
if not issubclass(custom_layer, tf.keras.layers.Layer):
|
374
|
-
raise Exception('
|
374
|
+
raise Exception('Custom layer should be inherit from tf.keras.layers.Layer')
|
375
375
|
|
376
376
|
leap_binder.set_custom_layer(custom_layer, name)
|
377
377
|
|
@@ -19,20 +19,32 @@ class DefaultVisualizer(Enum):
|
|
19
19
|
|
20
20
|
|
21
21
|
def default_image_visualizer(data: npt.NDArray[np.float32]) -> LeapImage:
|
22
|
+
# remove batch dim
|
23
|
+
data = data[0]
|
24
|
+
|
22
25
|
rescaled_data = rescale_min_max(data)
|
23
26
|
return LeapImage(rescaled_data)
|
24
27
|
|
25
28
|
|
26
29
|
def default_graph_visualizer(data: npt.NDArray[np.float32]) -> LeapGraph:
|
30
|
+
# remove batch dim
|
31
|
+
data = data[0]
|
32
|
+
|
27
33
|
return LeapGraph(data)
|
28
34
|
|
29
35
|
|
30
36
|
def default_horizontal_bar_visualizer(data: npt.NDArray[np.float32]) -> LeapHorizontalBar:
|
37
|
+
# remove batch dim
|
38
|
+
data = data[0]
|
39
|
+
|
31
40
|
labels = [str(index) for index in range(data.shape[-1])]
|
32
41
|
return LeapHorizontalBar(data, labels)
|
33
42
|
|
34
43
|
|
35
44
|
def default_word_visualizer(data: npt.NDArray[np.float32]) -> LeapText:
|
45
|
+
# remove batch dim
|
46
|
+
data = data[0]
|
47
|
+
|
36
48
|
if hasattr(data, 'tolist'):
|
37
49
|
data = data.tolist()
|
38
50
|
words = [str(index[0]) if type(index) is list else str(index) for index in data]
|
@@ -40,10 +52,17 @@ def default_word_visualizer(data: npt.NDArray[np.float32]) -> LeapText:
|
|
40
52
|
|
41
53
|
|
42
54
|
def default_raw_data_visualizer(data: npt.NDArray[np.float32]) -> LeapText:
|
55
|
+
# remove batch dim
|
56
|
+
data = data[0]
|
57
|
+
|
43
58
|
return LeapText([str(data)])
|
44
59
|
|
45
60
|
|
46
61
|
def default_image_mask_visualizer(mask: npt.NDArray[np.float32], image: npt.NDArray[np.float32]) -> LeapImageMask:
|
62
|
+
# remove batch dim
|
63
|
+
mask = mask[0]
|
64
|
+
image = image[0]
|
65
|
+
|
47
66
|
n_different_labels = mask.shape[-1]
|
48
67
|
labels = [str(i) for i in range(n_different_labels)]
|
49
68
|
|
@@ -57,6 +76,10 @@ def default_image_mask_visualizer(mask: npt.NDArray[np.float32], image: npt.NDAr
|
|
57
76
|
|
58
77
|
|
59
78
|
def default_text_mask_visualizer(mask: npt.NDArray[np.float32], text_data: npt.NDArray[np.float32]) -> LeapTextMask:
|
79
|
+
# remove batch dim
|
80
|
+
mask = mask[0]
|
81
|
+
text_data = text_data[0]
|
82
|
+
|
60
83
|
words = default_word_visualizer(text_data).data
|
61
84
|
n_different_labels = mask.shape[-1]
|
62
85
|
labels = [str(i) for i in range(n_different_labels)]
|
@@ -19,12 +19,12 @@ code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZ
|
|
19
19
|
code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
|
20
20
|
code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
|
21
21
|
code_loader/inner_leap_binder/leapbinder.py,sha256=35hyesDdmjOD9wdrTLyayb-vm9aDfmEbMA0c4EQR1LA,25090
|
22
|
-
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=
|
22
|
+
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=F1qjyA0A1dFIUGT-YFnlR9YNHBS_bcLzjP5jxzmZXQw,19102
|
23
23
|
code_loader/leaploader.py,sha256=POUgD6x1GH_iF_eDGz-VLX4DsIl2kddufKVDdrA_K-U,19491
|
24
24
|
code_loader/utils.py,sha256=aw2i_fqW_ADjLB66FWZd9DfpCQ7mPdMyauROC5Nd51I,2197
|
25
25
|
code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
-
code_loader/visualizers/default_visualizers.py,sha256=
|
27
|
-
code_loader-1.0.
|
28
|
-
code_loader-1.0.
|
29
|
-
code_loader-1.0.
|
30
|
-
code_loader-1.0.
|
26
|
+
code_loader/visualizers/default_visualizers.py,sha256=pSNeucXepyyYFspHQbkV1nDGfpk4JwnMEGSOsWbLrj4,2581
|
27
|
+
code_loader-1.0.53.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
28
|
+
code_loader-1.0.53.dist-info/METADATA,sha256=jO5pY2aiuga9_e_CjGOIIafEPxXbMAeeEfeDnWyTMlU,888
|
29
|
+
code_loader-1.0.53.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
30
|
+
code_loader-1.0.53.dist-info/RECORD,,
|
File without changes
|
File without changes
|