Skip to content

Commit

Permalink
Conditional TFLite import as requested in #6
Browse files Browse the repository at this point in the history
  • Loading branch information
kahst committed Mar 28, 2022
1 parent f3f42fc commit 195de15
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
os.environ['CUDA_VISIBLE_DEVICES'] = ''

import numpy as np
from tensorflow import lite as tflite
from tensorflow import keras

import warnings
warnings.filterwarnings("ignore")

import config as cfg

# Import TFLite from runtrime or Tensorflow
# or import Keras; NOTE: we have to use TFLite
# if we want to use the metadata model or want
# to extract embeddings
if cfg.MODEL_PATH.endswith('.tflite'):
try:
import tflite_runtime.interpreter as tflite
except ModuleNotFoundError:
from tensorflow import lite as tflite
else:
from tensorflow import keras

INTERPRETER = None
M_INTERPRETER = None
PBMODEL = None
Expand Down

0 comments on commit 195de15

Please sign in to comment.