Spaces:
Sleeping
Sleeping
Debugging code in app.py.
Browse files
app.py
CHANGED
@@ -10,14 +10,11 @@ nltk.download('stopwords')
|
|
10 |
from sklearn.feature_extraction.text import CountVectorizer
|
11 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
12 |
|
13 |
-
from transformers import pipeline
|
14 |
-
|
15 |
# file name
|
16 |
-
|
17 |
-
model = pipeline("sentiment-analysis", model="michellejieli/NSFW_text_classifier")
|
18 |
|
19 |
# Load model from pickle file
|
20 |
-
|
21 |
|
22 |
|
23 |
# Process input text, including removing stopwords, converting to lowercase, and removing punctuation
|
@@ -40,7 +37,7 @@ def vectorize_text(text):
|
|
40 |
|
41 |
def predict(text):
|
42 |
text = vectorize_text(text)
|
43 |
-
prediction = model.predict(text)
|
44 |
return prediction
|
45 |
|
46 |
|
|
|
10 |
from sklearn.feature_extraction.text import CountVectorizer
|
11 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
12 |
|
|
|
|
|
13 |
# file name
|
14 |
+
lr_filename = 'logistic_regression.pkl'
|
|
|
15 |
|
16 |
# Load model from pickle file
|
17 |
+
model = pickle.load(open(lr_filename, 'rb'))
|
18 |
|
19 |
|
20 |
# Process input text, including removing stopwords, converting to lowercase, and removing punctuation
|
|
|
37 |
|
38 |
def predict(text):
|
39 |
text = vectorize_text(text)
|
40 |
+
prediction = model.predict(text)
|
41 |
return prediction
|
42 |
|
43 |
|