Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
|
|
22 |
bert_model = TFBertModel.from_pretrained("bert-base-uncased")
|
23 |
|
24 |
# Define function to create embeddings
|
25 |
-
def bert_embeddings(texts, max_length=
|
26 |
inputs = tokenizer(
|
27 |
texts.tolist(),
|
28 |
return_tensors="tf",
|
@@ -89,14 +89,14 @@ print("\nClassification Report:")
|
|
89 |
print(class_report)
|
90 |
|
91 |
# Save the trained model to a file
|
92 |
-
classifier.save("movie_sentiment_model.h5")
|
93 |
|
94 |
def fn(test_review):
|
95 |
review=remove_tags(test_review)
|
96 |
review=remove_stop_wrods(review)
|
97 |
cls_embeddings = bert_embeddings([review])
|
98 |
-
loaded_model = load_model("movie_sentiment_model.h5")
|
99 |
-
prediction =
|
100 |
return "Positive" if prediction[0] > 0.5 else "Negative"
|
101 |
|
102 |
description = "Give a review of a movie that you like(or hate, sarcasm intended XD) and the model will let you know just how much your review truely reflects your emotions. "
|
|
|
22 |
bert_model = TFBertModel.from_pretrained("bert-base-uncased")
|
23 |
|
24 |
# Define function to create embeddings
|
25 |
+
def bert_embeddings(texts, max_length=64):
|
26 |
inputs = tokenizer(
|
27 |
texts.tolist(),
|
28 |
return_tensors="tf",
|
|
|
89 |
print(class_report)
|
90 |
|
91 |
# Save the trained model to a file
|
92 |
+
#classifier.save("movie_sentiment_model.h5")
|
93 |
|
94 |
def fn(test_review):
|
95 |
review=remove_tags(test_review)
|
96 |
review=remove_stop_wrods(review)
|
97 |
cls_embeddings = bert_embeddings([review])
|
98 |
+
#loaded_model = load_model("movie_sentiment_model.h5")
|
99 |
+
prediction = classifier.predict(cls_embeddings)
|
100 |
return "Positive" if prediction[0] > 0.5 else "Negative"
|
101 |
|
102 |
description = "Give a review of a movie that you like(or hate, sarcasm intended XD) and the model will let you know just how much your review truely reflects your emotions. "
|