HoangTrungNguyen commited on
Commit
bb6be84
·
verified ·
1 Parent(s): 5cbcc6d

Upload scripts/decode_reimplementation.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/decode_reimplementation.py +13 -7
scripts/decode_reimplementation.py CHANGED
@@ -120,14 +120,20 @@ def import_stack():
120
  ARIMA = None
121
  statsmodels_import_error = f"{type(exc).__name__}: {exc}"
122
 
 
 
123
  tf_import_error = None
124
- try:
125
- import tensorflow as tf
126
- from tensorflow import keras
127
- except Exception as exc:
128
- tf = None
129
- keras = None
130
- tf_import_error = f"{type(exc).__name__}: {exc}"
 
 
 
 
131
 
132
  return {
133
  "np": np,
 
120
  ARIMA = None
121
  statsmodels_import_error = f"{type(exc).__name__}: {exc}"
122
 
123
+ tf = None
124
+ keras = None
125
  tf_import_error = None
126
+ disable_tf_when_torch_available = os.environ.get("DECODE_DISABLE_TENSORFLOW", "1") == "1"
127
+ if disable_tf_when_torch_available and torch is not None:
128
+ tf_import_error = "disabled because PyTorch is available"
129
+ else:
130
+ try:
131
+ import tensorflow as tf
132
+ from tensorflow import keras
133
+ except Exception as exc:
134
+ tf = None
135
+ keras = None
136
+ tf_import_error = f"{type(exc).__name__}: {exc}"
137
 
138
  return {
139
  "np": np,