Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,27 +4,31 @@ import warnings
|
|
4 |
import gradio as gr
|
5 |
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
|
6 |
import traceback
|
|
|
7 |
|
8 |
warnings.filterwarnings('ignore')
|
9 |
|
10 |
-
# Tentukan
|
11 |
-
|
|
|
|
|
|
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
# Logging untuk memeriksa apakah file ada
|
19 |
print("Checking if files exist:")
|
20 |
-
print("Model file exists:", os.path.exists(
|
21 |
-
print("Vectorizer file exists:", os.path.exists(
|
22 |
-
print("Label encoder file exists:", os.path.exists(
|
23 |
|
24 |
# Memuat model
|
25 |
-
loaded_model = joblib.load(
|
26 |
-
vectorizer = joblib.load(
|
27 |
-
label_encoder = joblib.load(
|
28 |
|
29 |
# Buat instance dari SentimentIntensityAnalyzer
|
30 |
analyzer = SentimentIntensityAnalyzer()
|
|
|
4 |
import gradio as gr
|
5 |
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
|
6 |
import traceback
|
7 |
+
from huggingface_hub import hf_hub_download
|
8 |
|
9 |
warnings.filterwarnings('ignore')
|
10 |
|
11 |
+
# Tentukan repository dan nama file model di Hugging Face Hub
|
12 |
+
repo_id = "renaldidafa/sentimentanalysis"
|
13 |
+
model_filename = 'model_DecisionTreeClassifier.pkl'
|
14 |
+
vectorizer_filename = 'tfidf_vectorizer.pkl'
|
15 |
+
label_encoder_filename = 'label_encoder.pkl'
|
16 |
|
17 |
+
# Unduh file model dari Hugging Face Hub
|
18 |
+
model_path = hf_hub_download(repo_id=repo_id, filename=model_filename)
|
19 |
+
vectorizer_path = hf_hub_download(repo_id=repo_id, filename=vectorizer_filename)
|
20 |
+
label_encoder_path = hf_hub_download(repo_id=repo_id, filename=label_encoder_filename)
|
21 |
|
22 |
# Logging untuk memeriksa apakah file ada
|
23 |
print("Checking if files exist:")
|
24 |
+
print("Model file exists:", os.path.exists(model_path))
|
25 |
+
print("Vectorizer file exists:", os.path.exists(vectorizer_path))
|
26 |
+
print("Label encoder file exists:", os.path.exists(label_encoder_path))
|
27 |
|
28 |
# Memuat model
|
29 |
+
loaded_model = joblib.load(model_path)
|
30 |
+
vectorizer = joblib.load(vectorizer_path)
|
31 |
+
label_encoder = joblib.load(label_encoder_path)
|
32 |
|
33 |
# Buat instance dari SentimentIntensityAnalyzer
|
34 |
analyzer = SentimentIntensityAnalyzer()
|