Spaces:
Running
Running
xxxxxx
commited on
Commit
·
583a758
1
Parent(s):
73ef696
update
Browse files
app.py
CHANGED
@@ -38,14 +38,14 @@ col1, col2 = st.columns([2, 1])
|
|
38 |
def classify_text(text):
|
39 |
# HuggingFace模型分类
|
40 |
hf_result = hf_classifier(text)[0]
|
41 |
-
hf_label =
|
42 |
hf_confidence = hf_result["score"]
|
43 |
|
44 |
# ONNX模型分类
|
45 |
inputs = tokenizer(text, return_tensors="np", padding=True, truncation=True)
|
46 |
onnx_result = onnx_session.run(None, dict(inputs))
|
47 |
onnx_probs = onnx_result[0][0]
|
48 |
-
onnx_label =
|
49 |
onnx_confidence = np.max(onnx_probs)
|
50 |
|
51 |
return {
|
@@ -64,7 +64,7 @@ with col1:
|
|
64 |
|
65 |
for model, result in results.items():
|
66 |
st.subheader(f"{model.upper()} 模型分类结果:")
|
67 |
-
label = "垃圾信息" if result["label"] == "
|
68 |
if label == "垃圾信息":
|
69 |
st.error(f"⚠️ {label}")
|
70 |
else:
|
|
|
38 |
def classify_text(text):
|
39 |
# HuggingFace模型分类
|
40 |
hf_result = hf_classifier(text)[0]
|
41 |
+
hf_label = hf_result["label"]
|
42 |
hf_confidence = hf_result["score"]
|
43 |
|
44 |
# ONNX模型分类
|
45 |
inputs = tokenizer(text, return_tensors="np", padding=True, truncation=True)
|
46 |
onnx_result = onnx_session.run(None, dict(inputs))
|
47 |
onnx_probs = onnx_result[0][0]
|
48 |
+
onnx_label = "spam" if onnx_probs[1] > onnx_probs[0] else "normal"
|
49 |
onnx_confidence = np.max(onnx_probs)
|
50 |
|
51 |
return {
|
|
|
64 |
|
65 |
for model, result in results.items():
|
66 |
st.subheader(f"{model.upper()} 模型分类结果:")
|
67 |
+
label = "垃圾信息" if result["label"] == "normal" else "正常信息"
|
68 |
if label == "垃圾信息":
|
69 |
st.error(f"⚠️ {label}")
|
70 |
else:
|