Skip to content

Commit cd4236d

Browse files
committed
log with loguru
1 parent 65540ca commit cd4236d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bioimageio/core/model_adapters/_tensorflow_model_adapter.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import List, Literal, Optional, Sequence, Union
44

55
import numpy as np
6+
from loguru import logger
67

78
from bioimageio.spec.common import FileSource
89
from bioimageio.spec.model import v0_4, v0_5
@@ -46,19 +47,19 @@ def __init__(
4647
)
4748
model_tf_version = weights.tensorflow_version
4849
if model_tf_version is None:
49-
warnings.warn(
50+
logger.warning(
5051
"The model does not specify the tensorflow version."
5152
+ f"Cannot check if it is compatible with intalled tensorflow {tf_version}."
5253
)
5354
elif model_tf_version > tf_version:
54-
warnings.warn(
55+
logger.warning(
5556
f"The model specifies a newer tensorflow version than installed: {model_tf_version} > {tf_version}."
5657
)
5758
elif (model_tf_version.major, model_tf_version.minor) != (
5859
tf_version.major,
5960
tf_version.minor,
6061
):
61-
warnings.warn(
62+
logger.warning(
6263
"The tensorflow version specified by the model does not match the installed: "
6364
+ f"{model_tf_version} != {tf_version}."
6465
)
@@ -70,7 +71,7 @@ def __init__(
7071

7172
# TODO tf device management
7273
if devices is not None:
73-
warnings.warn(
74+
logger.warning(
7475
f"Device management is not implemented for tensorflow yet, ignoring the devices {devices}"
7576
)
7677

@@ -108,7 +109,7 @@ def _get_network( # pyright: ignore[reportUnknownParameterType]
108109
weight_file, trainable=False, call_endpoint="serve_default"
109110
) # pyright: ignore[reportUnknownVariableType]
110111
except Exception:
111-
warnings.warn(f"error with `call_endpiont='serve': {e}")
112+
logger.warning(f"error with `call_endpiont='serve': {e}")
112113
raise e
113114
else:
114115
# 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]]:
239240
]
240241

241242
def unload(self) -> None:
242-
warnings.warn(
243+
logger.warning(
243244
"Device management is not implemented for keras yet, cannot unload model"
244245
)
245246

0 commit comments

Comments
 (0)