Spaces:
Sleeping
Sleeping
Commit
·
7afa047
1
Parent(s):
4991c1b
Small change
Browse files
app.py
CHANGED
@@ -3,8 +3,17 @@ from transformers import pipeline
|
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
6 |
-
#
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
|
10 |
@app.route("/classify/text", methods=["POST"])
|
|
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
6 |
+
# Define label mappings
|
7 |
+
id2label = {0: "not_bullying", 1: "bullying"}
|
8 |
+
label2id = {"not_bullying": 0, "bullying": 1}
|
9 |
+
|
10 |
+
# Load the text classification pipeline with label mappings
|
11 |
+
classifier = pipeline(
|
12 |
+
"text-classification",
|
13 |
+
model="Davephoenix/bert-bullying-detector",
|
14 |
+
id2label=id2label,
|
15 |
+
label2id=label2id,
|
16 |
+
)
|
17 |
|
18 |
|
19 |
@app.route("/classify/text", methods=["POST"])
|