3
3
from typing import List , Literal , Optional , Sequence , Union
4
4
5
5
import numpy as np
6
+ from loguru import logger
6
7
7
8
from bioimageio .spec .common import FileSource
8
9
from bioimageio .spec .model import v0_4 , v0_5
@@ -46,19 +47,19 @@ def __init__(
46
47
)
47
48
model_tf_version = weights .tensorflow_version
48
49
if model_tf_version is None :
49
- warnings . warn (
50
+ logger . warning (
50
51
"The model does not specify the tensorflow version."
51
52
+ f"Cannot check if it is compatible with intalled tensorflow { tf_version } ."
52
53
)
53
54
elif model_tf_version > tf_version :
54
- warnings . warn (
55
+ logger . warning (
55
56
f"The model specifies a newer tensorflow version than installed: { model_tf_version } > { tf_version } ."
56
57
)
57
58
elif (model_tf_version .major , model_tf_version .minor ) != (
58
59
tf_version .major ,
59
60
tf_version .minor ,
60
61
):
61
- warnings . warn (
62
+ logger . warning (
62
63
"The tensorflow version specified by the model does not match the installed: "
63
64
+ f"{ model_tf_version } != { tf_version } ."
64
65
)
@@ -70,7 +71,7 @@ def __init__(
70
71
71
72
# TODO tf device management
72
73
if devices is not None :
73
- warnings . warn (
74
+ logger . warning (
74
75
f"Device management is not implemented for tensorflow yet, ignoring the devices { devices } "
75
76
)
76
77
@@ -108,7 +109,7 @@ def _get_network( # pyright: ignore[reportUnknownParameterType]
108
109
weight_file , trainable = False , call_endpoint = "serve_default"
109
110
) # pyright: ignore[reportUnknownVariableType]
110
111
except Exception :
111
- warnings . warn (f"error with `call_endpiont='serve': { e } " )
112
+ logger . warning (f"error with `call_endpiont='serve': { e } " )
112
113
raise e
113
114
else :
114
115
# NOTE in tf1 the model needs to be loaded inside of the session, so we cannot preload the model
@@ -239,7 +240,7 @@ def forward(self, *input_tensors: Optional[Tensor]) -> List[Optional[Tensor]]:
239
240
]
240
241
241
242
def unload (self ) -> None :
242
- warnings . warn (
243
+ logger . warning (
243
244
"Device management is not implemented for keras yet, cannot unload model"
244
245
)
245
246
0 commit comments