Spaces:
Sleeping
Sleeping
Jiahuita
commited on
Commit
•
8f3a7a6
1
Parent(s):
60dc372
update on app.py
Browse files
app.py
CHANGED
@@ -16,10 +16,14 @@ tokenizer = None
|
|
16 |
def load_model_and_tokenizer():
|
17 |
global model, tokenizer
|
18 |
try:
|
|
|
19 |
model = load_model('news_classifier.h5')
|
|
|
|
|
20 |
with open('tokenizer.json', 'r') as f:
|
21 |
-
|
22 |
-
tokenizer = tokenizer_from_json(
|
|
|
23 |
except Exception as e:
|
24 |
print(f"Error loading model or tokenizer: {str(e)}")
|
25 |
raise e
|
|
|
16 |
def load_model_and_tokenizer():
|
17 |
global model, tokenizer
|
18 |
try:
|
19 |
+
# Load model
|
20 |
model = load_model('news_classifier.h5')
|
21 |
+
|
22 |
+
# Load tokenizer - fixing the JSON handling
|
23 |
with open('tokenizer.json', 'r') as f:
|
24 |
+
tokenizer_json = f.read() # Read as string
|
25 |
+
tokenizer = tokenizer_from_json(tokenizer_json) # Pass the string directly
|
26 |
+
|
27 |
except Exception as e:
|
28 |
print(f"Error loading model or tokenizer: {str(e)}")
|
29 |
raise e
|