Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,27 @@ sentiment_model_name = "uer/roberta-base-finetuned-jd-binary-chinese"
|
|
| 9 |
sentiment_tokenizer = AutoTokenizer.from_pretrained(sentiment_model_name)
|
| 10 |
sentiment_model = AutoModelForSequenceClassification.from_pretrained(sentiment_model_name)
|
| 11 |
sentiment_model.eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# --------- Multi-label Classification Model (Your model) ---------
|
| 14 |
label_dir = "./result"
|
|
|
|
| 9 |
sentiment_tokenizer = AutoTokenizer.from_pretrained(sentiment_model_name)
|
| 10 |
sentiment_model = AutoModelForSequenceClassification.from_pretrained(sentiment_model_name)
|
| 11 |
sentiment_model.eval()
|
| 12 |
+
if not os.path.exists("result"):
|
| 13 |
+
with zipfile.ZipFile("model_output.zip", "r") as zip_ref:
|
| 14 |
+
zip_ref.extractall(".")
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# 加载你的多标签分类模型
|
| 18 |
+
label_tokenizer = AutoTokenizer.from_pretrained("result")
|
| 19 |
+
label_model = AutoModelForSequenceClassification.from_pretrained("result", use_safetensors=True)
|
| 20 |
+
label_model.eval()
|
| 21 |
+
|
| 22 |
+
# 多标签类别
|
| 23 |
+
label_map = {
|
| 24 |
+
0: "Landscape & Culture",
|
| 25 |
+
1: "Service & Facilities",
|
| 26 |
+
2: "Experience & Atmosphere",
|
| 27 |
+
3: "Transportation Accessibility",
|
| 28 |
+
4: "Interactive Activities",
|
| 29 |
+
5: "Price & Consumption"
|
| 30 |
+
}
|
| 31 |
+
threshold = 0.5
|
| 32 |
+
|
| 33 |
|
| 34 |
# --------- Multi-label Classification Model (Your model) ---------
|
| 35 |
label_dir = "./result"
|