Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,17 +7,17 @@ from tensorflow.keras.models import load_model # load a pre-trained Keras model
|
|
7 |
import numpy as np # scientific computing in Python
|
8 |
import streamlit as st
|
9 |
|
10 |
-
from . import SVM_Linear_Model
|
11 |
from . import Logistic_Model
|
12 |
from . import vectorizer
|
13 |
-
from . import tokenizer
|
14 |
|
15 |
# load all the models and vectorizer (global vocabulary)
|
16 |
# Seq_model = load_model('./LSTM.h5') # Sequential
|
17 |
-
SVM_Linear_model = joblib.load(SVM_Linear_Model) # SVM
|
18 |
logistic_model = joblib.load(Logistic_Model) # Logistic
|
19 |
vectorizer = joblib.load(vectorizer) # global vocabulary
|
20 |
-
tokenizer = joblib.load(tokenizer)
|
21 |
|
22 |
def crawURL(url):
|
23 |
print(f"Crawling page: {url}")
|
@@ -69,17 +69,17 @@ def crawURL(url):
|
|
69 |
def process_api(text):
|
70 |
# Vectorize the text data
|
71 |
processed_text = vectorizer.transform([text])
|
72 |
-
sequence = tokenizer.texts_to_sequences([text])
|
73 |
-
padded_sequence = pad_sequences(sequence, maxlen=1000, padding='post')
|
74 |
# Get the predicted result from models
|
75 |
# Seq_Predicted = Seq_model.predict(padded_sequence)
|
76 |
-
SVM_Predicted = SVM_model.predict(processed_text).tolist()
|
77 |
Logistic_Predicted = logistic_model.predict(processed_text).tolist()
|
78 |
|
79 |
# predicted_label_index = np.argmax(Seq_Predicted)
|
80 |
return {
|
81 |
'Article_Content': text,
|
82 |
-
'SVM_Predicted': int(SVM_Predicted[0]),
|
83 |
'Logistic_Predicted': int(Logistic_Predicted[0])
|
84 |
}
|
85 |
|
|
|
7 |
import numpy as np # scientific computing in Python
|
8 |
import streamlit as st
|
9 |
|
10 |
+
# from . import SVM_Linear_Model
|
11 |
from . import Logistic_Model
|
12 |
from . import vectorizer
|
13 |
+
# from . import tokenizer
|
14 |
|
15 |
# load all the models and vectorizer (global vocabulary)
|
16 |
# Seq_model = load_model('./LSTM.h5') # Sequential
|
17 |
+
# SVM_Linear_model = joblib.load(SVM_Linear_Model) # SVM
|
18 |
logistic_model = joblib.load(Logistic_Model) # Logistic
|
19 |
vectorizer = joblib.load(vectorizer) # global vocabulary
|
20 |
+
# tokenizer = joblib.load(tokenizer)
|
21 |
|
22 |
def crawURL(url):
|
23 |
print(f"Crawling page: {url}")
|
|
|
69 |
def process_api(text):
|
70 |
# Vectorize the text data
|
71 |
processed_text = vectorizer.transform([text])
|
72 |
+
# sequence = tokenizer.texts_to_sequences([text])
|
73 |
+
# padded_sequence = pad_sequences(sequence, maxlen=1000, padding='post')
|
74 |
# Get the predicted result from models
|
75 |
# Seq_Predicted = Seq_model.predict(padded_sequence)
|
76 |
+
# SVM_Predicted = SVM_model.predict(processed_text).tolist()
|
77 |
Logistic_Predicted = logistic_model.predict(processed_text).tolist()
|
78 |
|
79 |
# predicted_label_index = np.argmax(Seq_Predicted)
|
80 |
return {
|
81 |
'Article_Content': text,
|
82 |
+
# 'SVM_Predicted': int(SVM_Predicted[0]),
|
83 |
'Logistic_Predicted': int(Logistic_Predicted[0])
|
84 |
}
|
85 |
|