Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
import plotly.graph_objects as go
|
4 |
-
from transformers import pipeline
|
5 |
import numpy as np
|
6 |
from tqdm.auto import tqdm
|
7 |
import warnings
|
@@ -26,10 +26,8 @@ def initialize_pipeline():
|
|
26 |
try:
|
27 |
print("⏳ 正在載入情緒分析模型 (Hugging Face)...")
|
28 |
MODEL_NAME = "cardiffnlp/twitter-roberta-base-sentiment"
|
29 |
-
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
30 |
-
model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
|
31 |
SENTIMENT_PIPELINE = pipeline(
|
32 |
-
"sentiment-analysis", model=
|
33 |
)
|
34 |
print("✅ 模型載入成功!")
|
35 |
except Exception as e:
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
import plotly.graph_objects as go
|
4 |
+
from transformers import pipeline
|
5 |
import numpy as np
|
6 |
from tqdm.auto import tqdm
|
7 |
import warnings
|
|
|
26 |
try:
|
27 |
print("⏳ 正在載入情緒分析模型 (Hugging Face)...")
|
28 |
MODEL_NAME = "cardiffnlp/twitter-roberta-base-sentiment"
|
|
|
|
|
29 |
SENTIMENT_PIPELINE = pipeline(
|
30 |
+
"sentiment-analysis", model=MODEL_NAME, tokenizer=MODEL_NAME, device=-1
|
31 |
)
|
32 |
print("✅ 模型載入成功!")
|
33 |
except Exception as e:
|