diff --git a/doctr/file_utils.py b/doctr/file_utils.py index c201ffbb77..7f35b34ae8 100644 --- a/doctr/file_utils.py +++ b/doctr/file_utils.py @@ -76,13 +76,13 @@ " is installed and that either USE_TF or USE_TORCH is enabled." ) -if _tf_available: # Compatibility fix to make sure tf.keras stays at Keras 2 - if "TF_USE_LEGACY_KERAS" not in os.environ: - os.environ["TF_USE_LEGACY_KERAS"] = "1" - elif os.environ["TF_USE_LEGACY_KERAS"] != "1": - raise ValueError( - "docTR is only compatible with Keras 2, but you have explicitly set `TF_USE_LEGACY_KERAS` to `0`. " - ) +# Compatibility fix to make sure tf.keras stays at Keras 2 +if "TF_USE_LEGACY_KERAS" not in os.environ: + os.environ["TF_USE_LEGACY_KERAS"] = "1" +elif os.environ["TF_USE_LEGACY_KERAS"] != "1": + raise ValueError( + "docTR is only compatible with Keras 2, but you have explicitly set `TF_USE_LEGACY_KERAS` to `0`. " + ) def requires_package(name: str, extra_message: Optional[str] = None) -> None: # pragma: no cover