Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import tensorflow as tf
|
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
# Load the trained model
|
| 6 |
-
model = tf.keras.models.load_model("
|
| 7 |
|
| 8 |
# Load Preprocessing Function
|
| 9 |
import dill
|
|
@@ -11,7 +11,7 @@ with open("preprocessing1.pkl", "rb") as f:
|
|
| 11 |
clean_text = dill.load(f)
|
| 12 |
|
| 13 |
# Load Text Vectorization Layer from SavedModel
|
| 14 |
-
vectorizer = tf.saved_model.load("
|
| 15 |
|
| 16 |
# Define News Categories
|
| 17 |
news_categories = ["Business", "Sci/Tech", "Sports", "World"]
|
|
@@ -31,7 +31,7 @@ if st.button("Classify"):
|
|
| 31 |
text_sequence = vectorizer([processed_text])
|
| 32 |
|
| 33 |
# Convert to numpy array (model expects batch input)
|
| 34 |
-
|
| 35 |
|
| 36 |
# Predict Category
|
| 37 |
prediction = model.predict(text_sequence)
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
# Load the trained model
|
| 6 |
+
model = tf.keras.models.load_model("news_classification_rnn1.h5")
|
| 7 |
|
| 8 |
# Load Preprocessing Function
|
| 9 |
import dill
|
|
|
|
| 11 |
clean_text = dill.load(f)
|
| 12 |
|
| 13 |
# Load Text Vectorization Layer from SavedModel
|
| 14 |
+
vectorizer = tf.saved_model.load("vector")
|
| 15 |
|
| 16 |
# Define News Categories
|
| 17 |
news_categories = ["Business", "Sci/Tech", "Sports", "World"]
|
|
|
|
| 31 |
text_sequence = vectorizer([processed_text])
|
| 32 |
|
| 33 |
# Convert to numpy array (model expects batch input)
|
| 34 |
+
|
| 35 |
|
| 36 |
# Predict Category
|
| 37 |
prediction = model.predict(text_sequence)
|