Spaces:
Sleeping
Sleeping
T-Phong
commited on
Commit
·
bca7346
1
Parent(s):
3d5a84a
encode input
Browse files- app.py +2 -0
- model.py +2 -1
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from flask import Flask, request, jsonify
|
| 2 |
from flask_cors import CORS
|
| 3 |
import logging
|
|
|
|
| 4 |
|
| 5 |
# Cấu hình logging cho app
|
| 6 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -41,6 +42,7 @@ def predict():
|
|
| 41 |
# Gọi hàm dự đoán từ model
|
| 42 |
try:
|
| 43 |
if sentiment_type == "3sentiment":
|
|
|
|
| 44 |
sentiment, score = predict_sentiment_3sentiment(text_to_predict)
|
| 45 |
elif sentiment_type == "5sentiment":
|
| 46 |
sentiment, score = predict_sentiment_5sentiment(text_to_predict)
|
|
|
|
| 1 |
from flask import Flask, request, jsonify
|
| 2 |
from flask_cors import CORS
|
| 3 |
import logging
|
| 4 |
+
from pyvi import ViTokenizer
|
| 5 |
|
| 6 |
# Cấu hình logging cho app
|
| 7 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
| 42 |
# Gọi hàm dự đoán từ model
|
| 43 |
try:
|
| 44 |
if sentiment_type == "3sentiment":
|
| 45 |
+
text_to_predict = ViTokenizer.tokenize(text_to_predict)
|
| 46 |
sentiment, score = predict_sentiment_3sentiment(text_to_predict)
|
| 47 |
elif sentiment_type == "5sentiment":
|
| 48 |
sentiment, score = predict_sentiment_5sentiment(text_to_predict)
|
model.py
CHANGED
|
@@ -5,11 +5,12 @@ from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
|
| 5 |
import torch.nn.functional as F
|
| 6 |
import logging
|
| 7 |
|
|
|
|
| 8 |
# Cấu hình logging
|
| 9 |
logging.basicConfig(level=logging.INFO)
|
| 10 |
logger = logging.getLogger(__name__)
|
| 11 |
|
| 12 |
-
model_name_3sentiment = "phongnt251199/phobert-sentiment-reviews-
|
| 13 |
model_name_5sentiment = "phongnt251199/phobert-sentiment-reviews-v4"
|
| 14 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 15 |
logger.info(f"Device being used: {device}")
|
|
|
|
| 5 |
import torch.nn.functional as F
|
| 6 |
import logging
|
| 7 |
|
| 8 |
+
|
| 9 |
# Cấu hình logging
|
| 10 |
logging.basicConfig(level=logging.INFO)
|
| 11 |
logger = logging.getLogger(__name__)
|
| 12 |
|
| 13 |
+
model_name_3sentiment = "phongnt251199/phobert-sentiment-reviews-v6"
|
| 14 |
model_name_5sentiment = "phongnt251199/phobert-sentiment-reviews-v4"
|
| 15 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 16 |
logger.info(f"Device being used: {device}")
|
requirements.txt
CHANGED
|
@@ -5,3 +5,4 @@ openpyxl
|
|
| 5 |
torch
|
| 6 |
transformers
|
| 7 |
gunicorn
|
|
|
|
|
|
| 5 |
torch
|
| 6 |
transformers
|
| 7 |
gunicorn
|
| 8 |
+
pyvi
|