Update pipeline.py
Browse files- pipeline.py +2 -3
pipeline.py
CHANGED
|
@@ -3,7 +3,6 @@ import tensorflow as tf
|
|
| 3 |
from tensorflow.keras.preprocessing.sequence import pad_sequences
|
| 4 |
from tensorflow.keras.preprocessing.text import tokenizer_from_json
|
| 5 |
import json
|
| 6 |
-
import os
|
| 7 |
|
| 8 |
class Pipeline:
|
| 9 |
def __init__(self):
|
|
@@ -16,9 +15,9 @@ class Pipeline:
|
|
| 16 |
# Load model (SavedModel format)
|
| 17 |
self.model = tf.keras.models.load_model(".")
|
| 18 |
|
| 19 |
-
#
|
| 20 |
self.label_map = None
|
| 21 |
-
if
|
| 22 |
with open("label_map.json", "r", encoding="utf-8") as f:
|
| 23 |
self.label_map = json.load(f)
|
| 24 |
|
|
|
|
| 3 |
from tensorflow.keras.preprocessing.sequence import pad_sequences
|
| 4 |
from tensorflow.keras.preprocessing.text import tokenizer_from_json
|
| 5 |
import json
|
|
|
|
| 6 |
|
| 7 |
class Pipeline:
|
| 8 |
def __init__(self):
|
|
|
|
| 15 |
# Load model (SavedModel format)
|
| 16 |
self.model = tf.keras.models.load_model(".")
|
| 17 |
|
| 18 |
+
# Optional: load label map
|
| 19 |
self.label_map = None
|
| 20 |
+
if tf.io.gfile.exists("label_map.json"):
|
| 21 |
with open("label_map.json", "r", encoding="utf-8") as f:
|
| 22 |
self.label_map = json.load(f)
|
| 23 |
|