code-loader 1.0.94__tar.gz → 1.0.96__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.96}/PKG-INFO +1 -1
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/contract/datasetclasses.py +0 -16
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/inner_leap_binder/leapbinder.py +5 -29
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/inner_leap_binder/leapbinder_decorators.py +1 -87
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/leaploader.py +1 -43
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/leaploaderbase.py +1 -9
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/utils.py +2 -12
- {code_loader-1.0.94 → code_loader-1.0.96}/pyproject.toml +1 -1
- {code_loader-1.0.94 → code_loader-1.0.96}/LICENSE +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/README.md +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.94 → code_loader-1.0.96}/code_loader/visualizers/default_visualizers.py +0 -0
|
@@ -38,9 +38,6 @@ 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[Union[str, int], Union[List[str], List[int]]]] = None # in use only for element instance
|
|
42
|
-
instance_to_sample_ids_mappings: Optional[Dict[Union[str, int], Union[str, int]]] = None # in use only for element instance
|
|
43
|
-
|
|
44
41
|
|
|
45
42
|
def __post_init__(self) -> None:
|
|
46
43
|
def is_valid_string(s: str) -> bool:
|
|
@@ -68,14 +65,8 @@ class PreprocessResponse:
|
|
|
68
65
|
assert self.sample_ids is not None
|
|
69
66
|
return len(self.sample_ids)
|
|
70
67
|
|
|
71
|
-
@dataclass
|
|
72
|
-
class ElementInstance:
|
|
73
|
-
name: str
|
|
74
|
-
mask: npt.NDArray[np.float32]
|
|
75
|
-
# instance_filling_type: InstanceFillingType # TODO: implement InstanceFillingType
|
|
76
68
|
|
|
77
69
|
SectionCallableInterface = Callable[[Union[int, str], PreprocessResponse], npt.NDArray[np.float32]]
|
|
78
|
-
InstanceCallableInterface = Callable[[int, PreprocessResponse], List[ElementInstance]]
|
|
79
70
|
|
|
80
71
|
MetadataSectionCallableInterface = Union[
|
|
81
72
|
Callable[[Union[int, str], PreprocessResponse], int],
|
|
@@ -197,10 +188,6 @@ class InputHandler(DatasetBaseHandler):
|
|
|
197
188
|
shape: Optional[List[int]] = None
|
|
198
189
|
channel_dim: Optional[int] = -1
|
|
199
190
|
|
|
200
|
-
@dataclass
|
|
201
|
-
class ElementInstanceMasksHandler:
|
|
202
|
-
name: str
|
|
203
|
-
function: InstanceCallableInterface
|
|
204
191
|
|
|
205
192
|
@dataclass
|
|
206
193
|
class GroundTruthHandler(DatasetBaseHandler):
|
|
@@ -236,7 +223,6 @@ class DatasetIntegrationSetup:
|
|
|
236
223
|
unlabeled_data_preprocess: Optional[UnlabeledDataPreprocessHandler] = None
|
|
237
224
|
visualizers: List[VisualizerHandler] = field(default_factory=list)
|
|
238
225
|
inputs: List[InputHandler] = field(default_factory=list)
|
|
239
|
-
instance_masks: List[ElementInstanceMasksHandler] = field(default_factory=list)
|
|
240
226
|
ground_truths: List[GroundTruthHandler] = field(default_factory=list)
|
|
241
227
|
metadata: List[MetadataHandler] = field(default_factory=list)
|
|
242
228
|
prediction_types: List[PredictionTypeHandler] = field(default_factory=list)
|
|
@@ -253,5 +239,3 @@ class DatasetSample:
|
|
|
253
239
|
metadata_is_none: Dict[str, bool]
|
|
254
240
|
index: Union[int, str]
|
|
255
241
|
state: DataStateEnum
|
|
256
|
-
instance_masks: Optional[Dict[str, List[ElementInstance]]] = None
|
|
257
|
-
|
|
@@ -10,15 +10,14 @@ from code_loader.contract.datasetclasses import SectionCallableInterface, InputH
|
|
|
10
10
|
MetadataSectionCallableInterface, UnlabeledDataPreprocessHandler, CustomLayerHandler, MetricHandler, \
|
|
11
11
|
CustomCallableInterfaceMultiArgs, ConfusionMatrixCallableInterfaceMultiArgs, LeapData, \
|
|
12
12
|
CustomMultipleReturnCallableInterfaceMultiArgs, DatasetBaseHandler, custom_latent_space_attribute, \
|
|
13
|
-
RawInputsForHeatmap, VisualizerHandlerData, MetricHandlerData, CustomLossHandlerData, SamplePreprocessResponse
|
|
14
|
-
ElementInstanceMasksHandler, InstanceCallableInterface
|
|
13
|
+
RawInputsForHeatmap, VisualizerHandlerData, MetricHandlerData, CustomLossHandlerData, SamplePreprocessResponse
|
|
15
14
|
from code_loader.contract.enums import LeapDataType, DataStateEnum, DataStateType, MetricDirection, DatasetMetadataType
|
|
16
15
|
from code_loader.contract.mapping import NodeConnection, NodeMapping, NodeMappingType
|
|
17
16
|
from code_loader.contract.responsedataclasses import DatasetTestResultPayload
|
|
18
17
|
from code_loader.contract.visualizer_classes import map_leap_data_type_to_visualizer_class
|
|
19
18
|
from code_loader.default_losses import loss_name_to_function
|
|
20
19
|
from code_loader.default_metrics import metrics_names_to_functions_and_direction
|
|
21
|
-
from code_loader.utils import to_numpy_return_wrapper, get_shape
|
|
20
|
+
from code_loader.utils import to_numpy_return_wrapper, get_shape
|
|
22
21
|
from code_loader.visualizers.default_visualizers import DefaultVisualizer, \
|
|
23
22
|
default_graph_visualizer, \
|
|
24
23
|
default_image_visualizer, default_horizontal_bar_visualizer, default_word_visualizer, \
|
|
@@ -235,30 +234,6 @@ class LeapBinder:
|
|
|
235
234
|
|
|
236
235
|
self._encoder_names.append(name)
|
|
237
236
|
|
|
238
|
-
|
|
239
|
-
def set_instance_masks(self, function: InstanceCallableInterface, name: str) -> None:
|
|
240
|
-
"""
|
|
241
|
-
Set the input handler function.
|
|
242
|
-
|
|
243
|
-
Args:
|
|
244
|
-
function (SectionCallableInterface): The input handler function.
|
|
245
|
-
name (str): The name of the input section.
|
|
246
|
-
channel_dim (int): The dimension of the channels axis
|
|
247
|
-
|
|
248
|
-
Example:
|
|
249
|
-
def input_encoder(subset: PreprocessResponse, index: int) -> np.ndarray:
|
|
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)
|
|
257
|
-
"""
|
|
258
|
-
function = to_numpy_return_masks_wrapper(function)
|
|
259
|
-
self.setup_container.instance_masks.append(ElementInstanceMasksHandler(name, function))
|
|
260
|
-
|
|
261
|
-
|
|
262
237
|
def add_custom_loss(self, function: CustomCallableInterface, name: str) -> None:
|
|
263
238
|
"""
|
|
264
239
|
Add a custom loss function to the setup.
|
|
@@ -538,9 +513,10 @@ class LeapBinder:
|
|
|
538
513
|
for i, (single_metadata_name, single_metadata_result) in enumerate(raw_result.items()):
|
|
539
514
|
metadata_test_result = metadata_test_result_payloads[i]
|
|
540
515
|
|
|
541
|
-
if not isinstance(single_metadata_result, (int, str, bool, float, np.unsignedinteger,
|
|
516
|
+
if not isinstance(single_metadata_result, (int, str, bool, float, np.unsignedinteger,
|
|
517
|
+
np.signedinteger, np.bool_, np.floating, type(None))):
|
|
542
518
|
raise Exception(f"Unsupported return type of metadata {single_metadata_name}."
|
|
543
|
-
f"The return type should be one of [int, float, str, bool]. Got {type(single_metadata_result)}")
|
|
519
|
+
f"The return type should be one of [int, float, str, bool, None]. Got {type(single_metadata_result)}")
|
|
544
520
|
|
|
545
521
|
metadata_type = None
|
|
546
522
|
if single_metadata_result is None:
|
{code_loader-1.0.94 → code_loader-1.0.96}/code_loader/inner_leap_binder/leapbinder_decorators.py
RENAMED
|
@@ -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, SamplePreprocessResponse
|
|
11
|
+
ConfusionMatrixElement, SamplePreprocessResponse
|
|
12
12
|
from code_loader.contract.enums import MetricDirection, LeapDataType, DatasetMetadataType
|
|
13
13
|
from code_loader import leap_binder
|
|
14
14
|
from code_loader.contract.mapping import NodeMapping, NodeMappingType, NodeConnection
|
|
@@ -270,60 +270,6 @@ def tensorleap_preprocess():
|
|
|
270
270
|
|
|
271
271
|
return decorating_function
|
|
272
272
|
|
|
273
|
-
def tensorleap_element_instance_preprocess(instance_mask_encoder: Callable[[int, PreprocessResponse], List[PreprocessResponse]]):
|
|
274
|
-
def decorating_function(user_function: Callable[[], List[PreprocessResponse]]):
|
|
275
|
-
def user_function_instance() -> List[PreprocessResponse]:
|
|
276
|
-
result = user_function()
|
|
277
|
-
for preprocess_response in result:
|
|
278
|
-
sample_ids_to_instance_mappings = {}
|
|
279
|
-
instance_to_sample_ids_mappings = {}
|
|
280
|
-
all_sample_ids = preprocess_response.sample_ids.copy()
|
|
281
|
-
for sample_id in preprocess_response.sample_ids:
|
|
282
|
-
instances_masks = instance_mask_encoder(sample_id, preprocess_response)
|
|
283
|
-
instances_ids = [f'{sample_id}_{instance_id}' for instance_id in range(len(instances_masks))]
|
|
284
|
-
sample_ids_to_instance_mappings[sample_id] = instances_ids
|
|
285
|
-
instance_to_sample_ids_mappings[sample_id] = sample_id
|
|
286
|
-
for instance_id in instances_ids:
|
|
287
|
-
instance_to_sample_ids_mappings[instance_id] = sample_id
|
|
288
|
-
all_sample_ids.extend(instances_ids)
|
|
289
|
-
preprocess_response.sample_ids_to_instance_mappings = sample_ids_to_instance_mappings
|
|
290
|
-
preprocess_response.instance_to_sample_ids_mappings = instance_to_sample_ids_mappings
|
|
291
|
-
preprocess_response.sample_ids = all_sample_ids
|
|
292
|
-
return result
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
def metadata_is_instance(idx: str, preprocess: PreprocessResponse) -> str:
|
|
296
|
-
return "0"
|
|
297
|
-
leap_binder.set_preprocess(user_function_instance)
|
|
298
|
-
leap_binder.set_metadata(metadata_is_instance, "metadata_is_instance")
|
|
299
|
-
|
|
300
|
-
def _validate_input_args(*args, **kwargs):
|
|
301
|
-
assert len(args) == 0 and len(kwargs) == 0, \
|
|
302
|
-
(f'tensorleap_preprocess validation failed: '
|
|
303
|
-
f'The function should not take any arguments. Got {args} and {kwargs}.')
|
|
304
|
-
|
|
305
|
-
def _validate_result(result):
|
|
306
|
-
assert isinstance(result, list), \
|
|
307
|
-
(f'tensorleap_preprocess validation failed: '
|
|
308
|
-
f'The return type should be a list. Got {type(result)}.')
|
|
309
|
-
for i, response in enumerate(result):
|
|
310
|
-
assert isinstance(response, PreprocessResponse), \
|
|
311
|
-
(f'tensorleap_preprocess validation failed: '
|
|
312
|
-
f'Element #{i} in the return list should be a PreprocessResponse. Got {type(response)}.')
|
|
313
|
-
assert len(set(result)) == len(result), \
|
|
314
|
-
(f'tensorleap_preprocess validation failed: '
|
|
315
|
-
f'The return list should not contain duplicate PreprocessResponse objects.')
|
|
316
|
-
|
|
317
|
-
def inner(*args, **kwargs):
|
|
318
|
-
_validate_input_args(*args, **kwargs)
|
|
319
|
-
result = user_function_instance()
|
|
320
|
-
_validate_result(result)
|
|
321
|
-
return result
|
|
322
|
-
|
|
323
|
-
return inner
|
|
324
|
-
|
|
325
|
-
return decorating_function
|
|
326
|
-
|
|
327
273
|
|
|
328
274
|
def tensorleap_unlabeled_preprocess():
|
|
329
275
|
def decorating_function(user_function: Callable[[], PreprocessResponse]):
|
|
@@ -350,38 +296,6 @@ def tensorleap_unlabeled_preprocess():
|
|
|
350
296
|
return decorating_function
|
|
351
297
|
|
|
352
298
|
|
|
353
|
-
def tensorleap_instances_masks_encoder(name: str):
|
|
354
|
-
def decorating_function(user_function: InstanceCallableInterface):
|
|
355
|
-
leap_binder.set_instance_masks(user_function, name)
|
|
356
|
-
|
|
357
|
-
def _validate_input_args(sample_id: Union[int, str], preprocess_response: PreprocessResponse):
|
|
358
|
-
assert isinstance(sample_id, (int, str)), \
|
|
359
|
-
(f'tensorleap_input_encoder validation failed: '
|
|
360
|
-
f'Argument sample_id should be either int or str. Got {type(sample_id)}.')
|
|
361
|
-
assert isinstance(preprocess_response, PreprocessResponse), \
|
|
362
|
-
(f'tensorleap_input_encoder validation failed: '
|
|
363
|
-
f'Argument preprocess_response should be a PreprocessResponse. Got {type(preprocess_response)}.')
|
|
364
|
-
assert type(sample_id) == preprocess_response.sample_id_type, \
|
|
365
|
-
(f'tensorleap_input_encoder validation failed: '
|
|
366
|
-
f'Argument sample_id should be as the same type as defined in the preprocess response '
|
|
367
|
-
f'{preprocess_response.sample_id_type}. Got {type(sample_id)}.')
|
|
368
|
-
|
|
369
|
-
def _validate_result(result):
|
|
370
|
-
assert isinstance(result, list), \
|
|
371
|
-
(f'tensorleap_input_encoder validation failed: '
|
|
372
|
-
f'Unsupported return type. Should be a numpy array. Got {type(result)}.')
|
|
373
|
-
|
|
374
|
-
def inner(sample_id, preprocess_response):
|
|
375
|
-
_validate_input_args(sample_id, preprocess_response)
|
|
376
|
-
result = user_function(sample_id, preprocess_response)
|
|
377
|
-
_validate_result(result)
|
|
378
|
-
return result
|
|
379
|
-
|
|
380
|
-
return inner
|
|
381
|
-
|
|
382
|
-
return decorating_function
|
|
383
|
-
|
|
384
|
-
|
|
385
299
|
def tensorleap_input_encoder(name: str, channel_dim=-1, model_input_index=None):
|
|
386
300
|
def decorating_function(user_function: SectionCallableInterface):
|
|
387
301
|
for input_handler in leap_binder.setup_container.inputs:
|
|
@@ -14,8 +14,7 @@ import numpy.typing as npt
|
|
|
14
14
|
from code_loader.contract.datasetclasses import DatasetSample, DatasetBaseHandler, GroundTruthHandler, \
|
|
15
15
|
PreprocessResponse, VisualizerHandler, LeapData, \
|
|
16
16
|
PredictionTypeHandler, MetadataHandler, CustomLayerHandler, MetricHandler, VisualizerHandlerData, MetricHandlerData, \
|
|
17
|
-
MetricCallableReturnType, CustomLossHandlerData, CustomLossHandler, RawInputsForHeatmap, SamplePreprocessResponse
|
|
18
|
-
ElementInstance
|
|
17
|
+
MetricCallableReturnType, CustomLossHandlerData, CustomLossHandler, RawInputsForHeatmap, SamplePreprocessResponse
|
|
19
18
|
from code_loader.contract.enums import DataStateEnum, TestingSectionEnum, DataStateType, DatasetMetadataType
|
|
20
19
|
from code_loader.contract.exceptions import DatasetScriptException
|
|
21
20
|
from code_loader.contract.responsedataclasses import DatasetIntegParseResult, DatasetTestResultPayload, \
|
|
@@ -151,22 +150,6 @@ class LeapLoader(LeapLoaderBase):
|
|
|
151
150
|
state=state)
|
|
152
151
|
return sample
|
|
153
152
|
|
|
154
|
-
def get_sample_with_masks(self, state: DataStateEnum, sample_id: Union[int, str]) -> DatasetSample:
|
|
155
|
-
self.exec_script()
|
|
156
|
-
preprocess_result = self._preprocess_result()
|
|
157
|
-
if state == DataStateEnum.unlabeled and sample_id not in preprocess_result[state].sample_ids:
|
|
158
|
-
self._preprocess_result(update_unlabeled_preprocess=True)
|
|
159
|
-
|
|
160
|
-
metadata, metadata_is_none = self._get_metadata(state, sample_id)
|
|
161
|
-
sample = DatasetSample(inputs=self._get_inputs(state, sample_id),
|
|
162
|
-
gt=None if state == DataStateEnum.unlabeled else self._get_gt(state, sample_id),
|
|
163
|
-
metadata=metadata,
|
|
164
|
-
metadata_is_none=metadata_is_none,
|
|
165
|
-
index=sample_id,
|
|
166
|
-
state=state,
|
|
167
|
-
instance_masks=self._get_masks(state, sample_id))
|
|
168
|
-
return sample
|
|
169
|
-
|
|
170
153
|
def check_dataset(self) -> DatasetIntegParseResult:
|
|
171
154
|
test_payloads: List[DatasetTestResultPayload] = []
|
|
172
155
|
setup_response = None
|
|
@@ -454,16 +437,6 @@ class LeapLoader(LeapLoaderBase):
|
|
|
454
437
|
def _get_inputs(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, npt.NDArray[np.float32]]:
|
|
455
438
|
return self._get_dataset_handlers(global_leap_binder.setup_container.inputs, state, sample_id)
|
|
456
439
|
|
|
457
|
-
def _get_masks(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, List[ElementInstance]]:
|
|
458
|
-
preprocess_result = self._preprocess_result()
|
|
459
|
-
preprocess_state = preprocess_result[state]
|
|
460
|
-
result_agg = {}
|
|
461
|
-
for handler in global_leap_binder.setup_container.instance_masks:
|
|
462
|
-
handler_result = handler.function(sample_id, preprocess_state)
|
|
463
|
-
handler_name = handler.name
|
|
464
|
-
result_agg[handler_name] = handler_result
|
|
465
|
-
return result_agg
|
|
466
|
-
|
|
467
440
|
def _get_gt(self, state: DataStateEnum, sample_id: Union[int, str]) -> Dict[str, npt.NDArray[np.float32]]:
|
|
468
441
|
return self._get_dataset_handlers(global_leap_binder.setup_container.ground_truths, state, sample_id)
|
|
469
442
|
|
|
@@ -532,18 +505,3 @@ class LeapLoader(LeapLoaderBase):
|
|
|
532
505
|
raise Exception("Different id types in preprocess results")
|
|
533
506
|
|
|
534
507
|
return id_type
|
|
535
|
-
|
|
536
|
-
def get_instances_data(self, state: DataStateEnum) -> Tuple[Dict[Union[int, str], List[Union[int, str]]], Dict[Union[int, str], Union[int, str]], List[Union[int, str]]]:
|
|
537
|
-
"""
|
|
538
|
-
This Method get the data state and returns two dictionaries that holds the mapping of the sample ids to their
|
|
539
|
-
instances and the other way around and the sample ids array.
|
|
540
|
-
Args:
|
|
541
|
-
state: DataStateEnum state
|
|
542
|
-
Returns:
|
|
543
|
-
sample_ids_to_instance_mappings: sample id to instance mappings
|
|
544
|
-
instance_to_sample_ids_mappings: instance to sample ids mappings
|
|
545
|
-
sample_ids: sample ids array
|
|
546
|
-
"""
|
|
547
|
-
preprocess_result = self._preprocess_result()
|
|
548
|
-
preprocess_state = preprocess_result[state]
|
|
549
|
-
return preprocess_state.sample_ids_to_instance_mappings, preprocess_state.instance_to_sample_ids_mappings, preprocess_state.sample_ids
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from abc import abstractmethod
|
|
4
4
|
|
|
5
|
-
from typing import Dict, List, Union, Type, Optional
|
|
5
|
+
from typing import Dict, List, Union, Type, Optional
|
|
6
6
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
import numpy.typing as npt
|
|
@@ -64,14 +64,6 @@ class LeapLoaderBase:
|
|
|
64
64
|
def get_sample(self, state: DataStateEnum, sample_id: Union[int, str]) -> DatasetSample:
|
|
65
65
|
pass
|
|
66
66
|
|
|
67
|
-
@abstractmethod
|
|
68
|
-
def get_sample_with_masks(self, state: DataStateEnum, sample_id: Union[int, str]) -> DatasetSample:
|
|
69
|
-
pass
|
|
70
|
-
|
|
71
|
-
@abstractmethod
|
|
72
|
-
def get_instances_data(self, state: DataStateEnum) -> Tuple[Dict[Union[int, str], List[Union[int, str]]], Dict[Union[int, str], Union[int, str]], List[Union[int, str]]]:
|
|
73
|
-
pass
|
|
74
|
-
|
|
75
67
|
@abstractmethod
|
|
76
68
|
def check_dataset(self) -> DatasetIntegParseResult:
|
|
77
69
|
pass
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from types import TracebackType
|
|
4
|
-
from typing import List, Union, Tuple, Any
|
|
4
|
+
from typing import List, Union, Tuple, Any
|
|
5
5
|
import traceback
|
|
6
6
|
import numpy as np
|
|
7
7
|
import numpy.typing as npt
|
|
8
8
|
|
|
9
|
-
from code_loader.contract.datasetclasses import SectionCallableInterface, PreprocessResponse
|
|
10
|
-
InstanceCallableInterface, ElementInstance
|
|
9
|
+
from code_loader.contract.datasetclasses import SectionCallableInterface, PreprocessResponse
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
def to_numpy_return_wrapper(encoder_function: SectionCallableInterface) -> SectionCallableInterface:
|
|
@@ -18,15 +17,6 @@ def to_numpy_return_wrapper(encoder_function: SectionCallableInterface) -> Secti
|
|
|
18
17
|
|
|
19
18
|
return numpy_encoder_function
|
|
20
19
|
|
|
21
|
-
def to_numpy_return_masks_wrapper(encoder_function: InstanceCallableInterface) -> Callable[
|
|
22
|
-
[Union[int, str], PreprocessResponse], List[ElementInstance]]:
|
|
23
|
-
def numpy_encoder_function(idx: Union[int, str], samples: PreprocessResponse) -> List[ElementInstance]:
|
|
24
|
-
result = encoder_function(idx, samples)
|
|
25
|
-
for res in result:
|
|
26
|
-
res.mask = np.array(res.mask)
|
|
27
|
-
return result
|
|
28
|
-
return numpy_encoder_function
|
|
29
|
-
|
|
30
20
|
|
|
31
21
|
def get_root_traceback(exc_tb: TracebackType) -> TracebackType:
|
|
32
22
|
return_traceback = exc_tb
|
|
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
|
|
File without changes
|
{code_loader-1.0.94 → code_loader-1.0.96}/code_loader/experiment_api/workingspace_config_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|