code-loader 1.0.74__py3-none-any.whl → 1.0.75__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.
@@ -8,7 +8,7 @@ import numpy.typing as npt
8
8
  from code_loader.contract.datasetclasses import CustomCallableInterfaceMultiArgs, \
9
9
  CustomMultipleReturnCallableInterfaceMultiArgs, ConfusionMatrixCallableInterfaceMultiArgs, CustomCallableInterface, \
10
10
  VisualizerCallableInterface, MetadataSectionCallableInterface, PreprocessResponse, SectionCallableInterface, \
11
- ConfusionMatrixElement
11
+ ConfusionMatrixElement, SamplePreprocessResponse
12
12
  from code_loader.contract.enums import MetricDirection, LeapDataType
13
13
  from code_loader import leap_binder
14
14
  from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, LeapTextMask, LeapText, LeapGraph, \
@@ -30,18 +30,18 @@ def tensorleap_custom_metric(name: str,
30
30
 
31
31
  def _validate_input_args(*args, **kwargs) -> None:
32
32
  for i, arg in enumerate(args):
33
- assert isinstance(arg, np.ndarray), (f'tensorleap_custom_metric validation failed: '
33
+ assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (f'tensorleap_custom_metric validation failed: '
34
34
  f'Argument #{i} should be a numpy array. Got {type(arg)}.')
35
- if leap_binder.batch_size_to_validate:
35
+ if leap_binder.batch_size_to_validate and isinstance(arg, np.ndarray):
36
36
  assert arg.shape[0] == leap_binder.batch_size_to_validate, \
37
37
  (f'tensorleap_custom_metric validation failed: Argument #{i} '
38
38
  f'first dim should be as the batch size. Got {arg.shape[0]} '
39
39
  f'instead of {leap_binder.batch_size_to_validate}')
40
40
 
41
41
  for _arg_name, arg in kwargs.items():
42
- assert isinstance(arg, np.ndarray), (f'tensorleap_custom_metric validation failed: '
42
+ assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (f'tensorleap_custom_metric validation failed: '
43
43
  f'Argument {_arg_name} should be a numpy array. Got {type(arg)}.')
44
- if leap_binder.batch_size_to_validate:
44
+ if leap_binder.batch_size_to_validate and isinstance(arg, np.ndarray):
45
45
  assert arg.shape[0] == leap_binder.batch_size_to_validate, \
46
46
  (f'tensorleap_custom_metric validation failed: Argument {_arg_name} '
47
47
  f'first dim should be as the batch size. Got {arg.shape[0]} '
@@ -115,17 +115,17 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
115
115
 
116
116
  def _validate_input_args(*args, **kwargs):
117
117
  for i, arg in enumerate(args):
118
- assert isinstance(arg, np.ndarray), (f'tensorleap_custom_visualizer validation failed: '
118
+ assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (f'tensorleap_custom_visualizer validation failed: '
119
119
  f'Argument #{i} should be a numpy array. Got {type(arg)}.')
120
- if leap_binder.batch_size_to_validate:
120
+ if leap_binder.batch_size_to_validate and isinstance(arg, np.ndarray):
121
121
  assert arg.shape[0] != leap_binder.batch_size_to_validate, \
122
122
  (f'tensorleap_custom_visualizer validation failed: '
123
123
  f'Argument #{i} should be without batch dimension. ')
124
124
 
125
125
  for _arg_name, arg in kwargs.items():
126
- assert isinstance(arg, np.ndarray), (f'tensorleap_custom_visualizer validation failed: '
126
+ assert isinstance(arg, (np.ndarray, SamplePreprocessResponse)), (f'tensorleap_custom_visualizer validation failed: '
127
127
  f'Argument {_arg_name} should be a numpy array. Got {type(arg)}.')
128
- if leap_binder.batch_size_to_validate:
128
+ if leap_binder.batch_size_to_validate and isinstance(arg, np.ndarray):
129
129
  assert arg.shape[0] != leap_binder.batch_size_to_validate, \
130
130
  (f'tensorleap_custom_visualizer validation failed: Argument {_arg_name} '
131
131
  f'should be without batch dimension. ')
@@ -353,10 +353,10 @@ def tensorleap_custom_loss(name: str):
353
353
 
354
354
  leap_binder.add_custom_loss(user_function, name)
355
355
 
356
- valid_types = np.ndarray
356
+ valid_types = (np.ndarray, SamplePreprocessResponse)
357
357
  try:
358
358
  import tensorflow as tf
359
- valid_types = (np.ndarray, tf.Tensor)
359
+ valid_types = (np.ndarray, SamplePreprocessResponse, tf.Tensor)
360
360
  except ImportError:
361
361
  pass
362
362
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: code-loader
3
- Version: 1.0.74
3
+ Version: 1.0.75
4
4
  Summary:
5
5
  Home-page: https://github.com/tensorleap/code-loader
6
6
  License: MIT
@@ -20,13 +20,13 @@ code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZ
20
20
  code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
21
21
  code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
22
22
  code_loader/inner_leap_binder/leapbinder.py,sha256=0l9zjlF27tZwg6SnpyqVoAAgf9QHQcKpR9lg7vho2Xw,27065
23
- code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=B-XSw4xYF39kMPnMTRNKMYFg09whnfl7VSbcx195VG8,21626
23
+ code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=AI8Q9C_TiqpQqNmkCYZBeILFOaj1wn8LA64P8QbvNvs,21946
24
24
  code_loader/leaploader.py,sha256=Gggk5vzomqVqlYo14sQTlc7RIzhONYR-11hTLDKhwsA,24972
25
25
  code_loader/leaploaderbase.py,sha256=VH0vddRmkqLtcDlYPCO7hfz1_VbKo43lUdHDAbd4iJc,4198
26
26
  code_loader/utils.py,sha256=aw2i_fqW_ADjLB66FWZd9DfpCQ7mPdMyauROC5Nd51I,2197
27
27
  code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  code_loader/visualizers/default_visualizers.py,sha256=Ffx5VHVOe5ujBOsjBSxN_aIEVwFSQ6gbhTMG5aUS-po,2305
29
- code_loader-1.0.74.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
30
- code_loader-1.0.74.dist-info/METADATA,sha256=U5CAFcGLgU8DgBCJOmw66pChyzIZ3VETWozKKSonWeE,849
31
- code_loader-1.0.74.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
- code_loader-1.0.74.dist-info/RECORD,,
29
+ code_loader-1.0.75.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
30
+ code_loader-1.0.75.dist-info/METADATA,sha256=gs1VXUV1uIfBxojPyzvlbGGHkGE647DzwASp1HJiNHU,849
31
+ code_loader-1.0.75.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
+ code_loader-1.0.75.dist-info/RECORD,,