code-loader 1.0.99.dev8__py3-none-any.whl → 1.0.99.dev10__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 +66 -5
- {code_loader-1.0.99.dev8.dist-info → code_loader-1.0.99.dev10.dist-info}/METADATA +1 -1
- {code_loader-1.0.99.dev8.dist-info → code_loader-1.0.99.dev10.dist-info}/RECORD +5 -5
- {code_loader-1.0.99.dev8.dist-info → code_loader-1.0.99.dev10.dist-info}/LICENSE +0 -0
- {code_loader-1.0.99.dev8.dist-info → code_loader-1.0.99.dev10.dist-info}/WHEEL +0 -0
@@ -17,6 +17,9 @@ from code_loader.contract.visualizer_classes import LeapImage, LeapImageMask, Le
|
|
17
17
|
from code_loader.inner_leap_binder.leapbinder import mapping_runtime_mode_env_var_mame
|
18
18
|
|
19
19
|
|
20
|
+
|
21
|
+
_called_from_inside_tl_decorator = 0
|
22
|
+
|
20
23
|
def _add_mapping_connection(user_unique_name, connection_destinations, arg_names, name, node_mapping_type):
|
21
24
|
main_node_mapping = NodeMapping(name, node_mapping_type, user_unique_name, arg_names=arg_names)
|
22
25
|
node_inputs = {}
|
@@ -41,6 +44,23 @@ def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]
|
|
41
44
|
class TempMapping:
|
42
45
|
pass
|
43
46
|
|
47
|
+
def inner():
|
48
|
+
class ModelPlaceholder:
|
49
|
+
def __init__(self):
|
50
|
+
self.model = load_model_func()
|
51
|
+
#keras interface
|
52
|
+
def __call__(self, arg):
|
53
|
+
ret = self.model(arg)
|
54
|
+
return ret.numpy()
|
55
|
+
|
56
|
+
# onnx runtime interface
|
57
|
+
def run(self, output_names, input_dict):
|
58
|
+
return self.model.run(output_names, input_dict)
|
59
|
+
|
60
|
+
|
61
|
+
return ModelPlaceholder()
|
62
|
+
|
63
|
+
|
44
64
|
def mapping_inner():
|
45
65
|
class ModelOutputPlaceholder:
|
46
66
|
def __init__(self):
|
@@ -78,11 +98,13 @@ def tensorleap_load_model(prediction_types: Optional[List[PredictionTypeHandler]
|
|
78
98
|
return ModelPlaceholder()
|
79
99
|
|
80
100
|
|
101
|
+
|
102
|
+
|
81
103
|
def final_inner():
|
82
104
|
if os.environ.get(mapping_runtime_mode_env_var_mame):
|
83
105
|
return mapping_inner()
|
84
106
|
else:
|
85
|
-
return
|
107
|
+
return inner()
|
86
108
|
|
87
109
|
return final_inner
|
88
110
|
|
@@ -185,7 +207,15 @@ def tensorleap_custom_metric(name: str,
|
|
185
207
|
|
186
208
|
def inner(*args, **kwargs):
|
187
209
|
_validate_input_args(*args, **kwargs)
|
188
|
-
|
210
|
+
|
211
|
+
global _called_from_inside_tl_decorator
|
212
|
+
_called_from_inside_tl_decorator += 1
|
213
|
+
|
214
|
+
try:
|
215
|
+
result = user_function(*args, **kwargs)
|
216
|
+
finally:
|
217
|
+
_called_from_inside_tl_decorator -= 1
|
218
|
+
|
189
219
|
_validate_result(result)
|
190
220
|
return result
|
191
221
|
|
@@ -268,7 +298,15 @@ def tensorleap_custom_visualizer(name: str, visualizer_type: LeapDataType,
|
|
268
298
|
|
269
299
|
def inner(*args, **kwargs):
|
270
300
|
_validate_input_args(*args, **kwargs)
|
271
|
-
|
301
|
+
|
302
|
+
global _called_from_inside_tl_decorator
|
303
|
+
_called_from_inside_tl_decorator += 1
|
304
|
+
|
305
|
+
try:
|
306
|
+
result = user_function(*args, **kwargs)
|
307
|
+
finally:
|
308
|
+
_called_from_inside_tl_decorator -= 1
|
309
|
+
|
272
310
|
_validate_result(result)
|
273
311
|
return result
|
274
312
|
|
@@ -340,7 +378,15 @@ def tensorleap_metadata(
|
|
340
378
|
return None
|
341
379
|
|
342
380
|
_validate_input_args(sample_id, preprocess_response)
|
343
|
-
|
381
|
+
|
382
|
+
global _called_from_inside_tl_decorator
|
383
|
+
_called_from_inside_tl_decorator += 1
|
384
|
+
|
385
|
+
try:
|
386
|
+
result = user_function(sample_id, preprocess_response)
|
387
|
+
finally:
|
388
|
+
_called_from_inside_tl_decorator -= 1
|
389
|
+
|
344
390
|
_validate_result(result)
|
345
391
|
return result
|
346
392
|
|
@@ -375,6 +421,7 @@ def tensorleap_preprocess():
|
|
375
421
|
return [None, None, None, None]
|
376
422
|
|
377
423
|
_validate_input_args(*args, **kwargs)
|
424
|
+
|
378
425
|
result = user_function()
|
379
426
|
_validate_result(result)
|
380
427
|
return result
|
@@ -446,6 +493,9 @@ def tensorleap_input_encoder(name: str, channel_dim=-1, model_input_index=None):
|
|
446
493
|
_validate_input_args(sample_id, preprocess_response)
|
447
494
|
result = user_function(sample_id, preprocess_response)
|
448
495
|
_validate_result(result)
|
496
|
+
|
497
|
+
if _called_from_inside_tl_decorator == 0:
|
498
|
+
result = np.expand_dims(result, axis=0)
|
449
499
|
return result
|
450
500
|
|
451
501
|
node_mapping_type = NodeMappingType.Input
|
@@ -510,6 +560,9 @@ def tensorleap_gt_encoder(name: str):
|
|
510
560
|
_validate_input_args(sample_id, preprocess_response)
|
511
561
|
result = user_function(sample_id, preprocess_response)
|
512
562
|
_validate_result(result)
|
563
|
+
|
564
|
+
if _called_from_inside_tl_decorator == 0:
|
565
|
+
result = np.expand_dims(result, axis=0)
|
513
566
|
return result
|
514
567
|
|
515
568
|
inner.node_mapping = NodeMapping(name, NodeMappingType.GroundTruth)
|
@@ -584,7 +637,15 @@ def tensorleap_custom_loss(name: str, connects_to=None):
|
|
584
637
|
|
585
638
|
def inner(*args, **kwargs):
|
586
639
|
_validate_input_args(*args, **kwargs)
|
587
|
-
|
640
|
+
|
641
|
+
global _called_from_inside_tl_decorator
|
642
|
+
_called_from_inside_tl_decorator += 1
|
643
|
+
|
644
|
+
try:
|
645
|
+
result = user_function(*args, **kwargs)
|
646
|
+
finally:
|
647
|
+
_called_from_inside_tl_decorator -= 1
|
648
|
+
|
588
649
|
_validate_result(result)
|
589
650
|
return result
|
590
651
|
|
@@ -21,13 +21,13 @@ code_loader/experiment_api/utils.py,sha256=XZHtxge12TS4H4-8PjV3sKuhp8Ud6ojAiIzTZ
|
|
21
21
|
code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaSbeTVzq-2ja_SQw4zi7LXwKL9cY,990
|
22
22
|
code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
|
23
23
|
code_loader/inner_leap_binder/leapbinder.py,sha256=FaX0kT-dEQJx4tS3LBfDxjf7Bi1LihkeEfLDHbyEbnM,31778
|
24
|
-
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=
|
24
|
+
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=BP0JQdHZgng-HSTWhdZlIwj6Vu3OGm6aNtTwJC0pvlY,32951
|
25
25
|
code_loader/leaploader.py,sha256=6SBhkhw2PVwCw1H4Krzl74CPG18n8F9NIrid1wEtTHs,26884
|
26
26
|
code_loader/leaploaderbase.py,sha256=VH0vddRmkqLtcDlYPCO7hfz1_VbKo43lUdHDAbd4iJc,4198
|
27
27
|
code_loader/utils.py,sha256=aw2i_fqW_ADjLB66FWZd9DfpCQ7mPdMyauROC5Nd51I,2197
|
28
28
|
code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
29
|
code_loader/visualizers/default_visualizers.py,sha256=669lBpLISLO6my5Qcgn1FLDDeZgHumPf252m4KHY4YM,2555
|
30
|
-
code_loader-1.0.99.
|
31
|
-
code_loader-1.0.99.
|
32
|
-
code_loader-1.0.99.
|
33
|
-
code_loader-1.0.99.
|
30
|
+
code_loader-1.0.99.dev10.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
31
|
+
code_loader-1.0.99.dev10.dist-info/METADATA,sha256=7fnnb4TUCR5SVKZK9WFXOWhjZX6Jr-g7c01TUnR-AWE,855
|
32
|
+
code_loader-1.0.99.dev10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
33
|
+
code_loader-1.0.99.dev10.dist-info/RECORD,,
|
File without changes
|
File without changes
|