Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -233,18 +233,9 @@ model, vectorizer, label_encoder = load_model()
|
|
| 233 |
# ✅ Prediction Function
|
| 234 |
def predict_category(text):
|
| 235 |
processed_text = [pre_process(text)]
|
| 236 |
-
|
| 237 |
-
# Vectorize the input
|
| 238 |
-
text_vectorized = vectorizer(processed_text).np.tolist()
|
| 239 |
-
|
| 240 |
-
# Pad the sequence
|
| 241 |
-
text_vectorized = pad_sequences(text_vectorized, padding='pre', maxlen=128)
|
| 242 |
-
|
| 243 |
-
# Model prediction
|
| 244 |
prediction = model.predict(text_vectorized)
|
| 245 |
category_idx = np.argmax(prediction, axis=1)[0]
|
| 246 |
-
|
| 247 |
-
# Return the category label
|
| 248 |
return label_encoder.inverse_transform([category_idx])[0]
|
| 249 |
|
| 250 |
|
|
|
|
| 233 |
# ✅ Prediction Function
|
| 234 |
def predict_category(text):
|
| 235 |
processed_text = [pre_process(text)]
|
| 236 |
+
text_vectorized = pad_sequences(vectorizer(processed_text).numpy().tolist(), padding='pre', maxlen=128)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
prediction = model.predict(text_vectorized)
|
| 238 |
category_idx = np.argmax(prediction, axis=1)[0]
|
|
|
|
|
|
|
| 239 |
return label_encoder.inverse_transform([category_idx])[0]
|
| 240 |
|
| 241 |
|