code-loader 1.0.94__tar.gz → 1.0.94.dev1__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.
Potentially problematic release.
This version of code-loader might be problematic. Click here for more details.
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/PKG-INFO +1 -1
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/contract/datasetclasses.py +6 -4
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/inner_leap_binder/leapbinder.py +3 -11
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/inner_leap_binder/leapbinder_decorators.py +13 -14
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/leaploader.py +2 -2
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/pyproject.toml +1 -1
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/LICENSE +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/README.md +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/leaploaderbase.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/utils.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.94.dev1}/code_loader/visualizers/default_visualizers.py +0 -0
|
@@ -38,14 +38,17 @@ class PreprocessResponse:
|
|
|
38
38
|
sample_ids: Optional[Union[List[str], List[int]]] = None
|
|
39
39
|
state: Optional[DataStateType] = None
|
|
40
40
|
sample_id_type: Optional[Union[Type[str], Type[int]]] = None
|
|
41
|
-
sample_ids_to_instance_mappings: Optional[Dict[
|
|
42
|
-
instance_to_sample_ids_mappings: Optional[Dict[
|
|
41
|
+
sample_ids_to_instance_mappings: Optional[Dict[str, List[str]]] = None # in use only for element instance
|
|
42
|
+
instance_to_sample_ids_mappings: Optional[Dict[str, str]] = None # in use only for element instance
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
def __post_init__(self) -> None:
|
|
46
46
|
def is_valid_string(s: str) -> bool:
|
|
47
47
|
return bool(re.match(r'^[A-Za-z0-9_]+$', s))
|
|
48
48
|
|
|
49
|
+
assert self.sample_ids_to_instance_mappings is None, f"Keep sample_ids_to_instance_mappings None when initializing PreprocessResponse"
|
|
50
|
+
assert self.instance_to_sample_ids_mappings is None, f"Keep instance_to_sample_ids_mappings None when initializing PreprocessResponse"
|
|
51
|
+
|
|
49
52
|
if self.length is not None and self.sample_ids is None:
|
|
50
53
|
self.sample_ids = [i for i in range(self.length)]
|
|
51
54
|
self.sample_id_type = int
|
|
@@ -72,10 +75,9 @@ class PreprocessResponse:
|
|
|
72
75
|
class ElementInstance:
|
|
73
76
|
name: str
|
|
74
77
|
mask: npt.NDArray[np.float32]
|
|
75
|
-
# instance_filling_type: InstanceFillingType # TODO: implement InstanceFillingType
|
|
76
78
|
|
|
77
79
|
SectionCallableInterface = Callable[[Union[int, str], PreprocessResponse], npt.NDArray[np.float32]]
|
|
78
|
-
InstanceCallableInterface = Callable[[int, PreprocessResponse], List[ElementInstance]]
|
|
80
|
+
InstanceCallableInterface = Callable[[Union[int, str], PreprocessResponse], List[ElementInstance]]
|
|
79
81
|
|
|
80
82
|
MetadataSectionCallableInterface = Union[
|
|
81
83
|
Callable[[Union[int, str], PreprocessResponse], int],
|
|
@@ -238,22 +238,14 @@ class LeapBinder:
|
|
|
238
238
|
|
|
239
239
|
def set_instance_masks(self, function: InstanceCallableInterface, name: str) -> None:
|
|
240
240
|
"""
|
|
241
|
-
Set the
|
|
241
|
+
Set the instance mask handler function.
|
|
242
242
|
|
|
243
243
|
Args:
|
|
244
244
|
function (SectionCallableInterface): The input handler function.
|
|
245
|
-
name (str): The name of the
|
|
246
|
-
channel_dim (int): The dimension of the channels axis
|
|
245
|
+
name (str): The name of the instance mask section.
|
|
247
246
|
|
|
248
247
|
Example:
|
|
249
|
-
|
|
250
|
-
# Return the processed input data for the given index and given subset response
|
|
251
|
-
img_path = subset.`data["images"][idx]
|
|
252
|
-
img = read_img(img_path)
|
|
253
|
-
img = normalize(img)
|
|
254
|
-
return img
|
|
255
|
-
|
|
256
|
-
leap_binder.set_input(input_encoder, name='input_encoder', channel_dim=-1)
|
|
248
|
+
leap_binder.set_input(input_encoder, name='input_encoder')
|
|
257
249
|
"""
|
|
258
250
|
function = to_numpy_return_masks_wrapper(function)
|
|
259
251
|
self.setup_container.instance_masks.append(ElementInstanceMasksHandler(name, function))
|
|
@@ -291,27 +291,26 @@ def tensorleap_element_instance_preprocess(instance_mask_encoder: Callable[[int,
|
|
|
291
291
|
preprocess_response.sample_ids = all_sample_ids
|
|
292
292
|
return result
|
|
293
293
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return "0"
|
|
294
|
+
def metadata_is_instance(idx: str, preprocess: PreprocessResponse) -> Dict[str, str]:
|
|
295
|
+
return {'is_instance': '0', 'orig_sample_id': preprocess.instance_to_sample_ids_mappings[idx]}
|
|
297
296
|
leap_binder.set_preprocess(user_function_instance)
|
|
298
297
|
leap_binder.set_metadata(metadata_is_instance, "metadata_is_instance")
|
|
299
298
|
|
|
300
299
|
def _validate_input_args(*args, **kwargs):
|
|
301
300
|
assert len(args) == 0 and len(kwargs) == 0, \
|
|
302
|
-
(f'
|
|
301
|
+
(f'tensorleap_element_instance_preprocess validation failed: '
|
|
303
302
|
f'The function should not take any arguments. Got {args} and {kwargs}.')
|
|
304
303
|
|
|
305
304
|
def _validate_result(result):
|
|
306
305
|
assert isinstance(result, list), \
|
|
307
|
-
(f'
|
|
306
|
+
(f'tensorleap_element_instance_preprocess validation failed: '
|
|
308
307
|
f'The return type should be a list. Got {type(result)}.')
|
|
309
308
|
for i, response in enumerate(result):
|
|
310
309
|
assert isinstance(response, PreprocessResponse), \
|
|
311
|
-
(f'
|
|
310
|
+
(f'tensorleap_element_instance_preprocess validation failed: '
|
|
312
311
|
f'Element #{i} in the return list should be a PreprocessResponse. Got {type(response)}.')
|
|
313
312
|
assert len(set(result)) == len(result), \
|
|
314
|
-
(f'
|
|
313
|
+
(f'tensorleap_element_instance_preprocess validation failed: '
|
|
315
314
|
f'The return list should not contain duplicate PreprocessResponse objects.')
|
|
316
315
|
|
|
317
316
|
def inner(*args, **kwargs):
|
|
@@ -354,21 +353,21 @@ def tensorleap_instances_masks_encoder(name: str):
|
|
|
354
353
|
def decorating_function(user_function: InstanceCallableInterface):
|
|
355
354
|
leap_binder.set_instance_masks(user_function, name)
|
|
356
355
|
|
|
357
|
-
def _validate_input_args(sample_id:
|
|
358
|
-
assert isinstance(sample_id,
|
|
359
|
-
(f'
|
|
360
|
-
f'Argument sample_id should be
|
|
356
|
+
def _validate_input_args(sample_id: str, preprocess_response: PreprocessResponse):
|
|
357
|
+
assert isinstance(sample_id, str), \
|
|
358
|
+
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
359
|
+
f'Argument sample_id should be str. Got {type(sample_id)}.')
|
|
361
360
|
assert isinstance(preprocess_response, PreprocessResponse), \
|
|
362
|
-
(f'
|
|
361
|
+
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
363
362
|
f'Argument preprocess_response should be a PreprocessResponse. Got {type(preprocess_response)}.')
|
|
364
363
|
assert type(sample_id) == preprocess_response.sample_id_type, \
|
|
365
|
-
(f'
|
|
364
|
+
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
366
365
|
f'Argument sample_id should be as the same type as defined in the preprocess response '
|
|
367
366
|
f'{preprocess_response.sample_id_type}. Got {type(sample_id)}.')
|
|
368
367
|
|
|
369
368
|
def _validate_result(result):
|
|
370
369
|
assert isinstance(result, list), \
|
|
371
|
-
(f'
|
|
370
|
+
(f'tensorleap_instances_masks_encoder validation failed: '
|
|
372
371
|
f'Unsupported return type. Should be a numpy array. Got {type(result)}.')
|
|
373
372
|
|
|
374
373
|
def inner(sample_id, preprocess_response):
|
|
@@ -164,7 +164,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
164
164
|
metadata_is_none=metadata_is_none,
|
|
165
165
|
index=sample_id,
|
|
166
166
|
state=state,
|
|
167
|
-
instance_masks=self.
|
|
167
|
+
instance_masks=self._get_instances_masks(state, sample_id))
|
|
168
168
|
return sample
|
|
169
169
|
|
|
170
170
|
def check_dataset(self) -> DatasetIntegParseResult:
|
|
@@ -454,7 +454,7 @@ class LeapLoader(LeapLoaderBase):
|
|
|
454
454
|
def _get_inputs(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, npt.NDArray[np.float32]]:
|
|
455
455
|
return self._get_dataset_handlers(global_leap_binder.setup_container.inputs, state, sample_id)
|
|
456
456
|
|
|
457
|
-
def
|
|
457
|
+
def _get_instances_masks(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, List[ElementInstance]]:
|
|
458
458
|
preprocess_result = self._preprocess_result()
|
|
459
459
|
preprocess_state = preprocess_result[state]
|
|
460
460
|
result_agg = {}
|
|
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.94 → code_loader-1.0.94.dev1}/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.94 → code_loader-1.0.94.dev1}/code_loader/experiment_api/experiment_context.py
RENAMED
|
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.94 → code_loader-1.0.94.dev1}/code_loader/visualizers/default_visualizers.py
RENAMED
|
File without changes
|