Spaces:
Runtime error
Runtime error
branching
Browse files
app.py
CHANGED
|
@@ -10,19 +10,21 @@ defaultTxt = "I hate you cancerous insects so much"
|
|
| 10 |
txt = st.text_area("Text to analyze", defaultTxt)
|
| 11 |
|
| 12 |
# Load tokenizer and model weights, try to default to RoBERTa.
|
| 13 |
-
match
|
| 14 |
-
|
|
|
|
| 15 |
tokenizerPath = "s-nlp/roberta_toxicity_classifier"
|
| 16 |
modelPath = "s-nlp/roberta_toxicity_classifier"
|
| 17 |
-
|
| 18 |
tokenizerPath = "citizenlab/distilbert-base-multilingual-cased-toxicity"
|
| 19 |
modelPath = "citizenlab/distilbert-base-multilingual-cased-toxicity"
|
| 20 |
-
|
| 21 |
tokenizerPath = "unitary/multilingual-toxic-xlm-roberta"
|
| 22 |
modelPath = "unitary/multilingual-toxic-xlm-roberta"
|
| 23 |
-
|
| 24 |
tokenizerPath = "s-nlp/roberta_toxicity_classifier"
|
| 25 |
modelPath = "s-nlp/roberta_toxicity_classifier"
|
|
|
|
| 26 |
tokenizer = AutoTokenizer.from_pretrained(tokenizerPath)
|
| 27 |
model = AutoModelForSequenceClassification.from_pretrained(modelPath)
|
| 28 |
|
|
|
|
| 10 |
txt = st.text_area("Text to analyze", defaultTxt)
|
| 11 |
|
| 12 |
# Load tokenizer and model weights, try to default to RoBERTa.
|
| 13 |
+
# Huggingface does not support Python 3.10 match statements and I'm too lazy to implement an equivalent.
|
| 14 |
+
|
| 15 |
+
if (option == "RoBERTa"):
|
| 16 |
tokenizerPath = "s-nlp/roberta_toxicity_classifier"
|
| 17 |
modelPath = "s-nlp/roberta_toxicity_classifier"
|
| 18 |
+
elif (option == "DistilBERT"):
|
| 19 |
tokenizerPath = "citizenlab/distilbert-base-multilingual-cased-toxicity"
|
| 20 |
modelPath = "citizenlab/distilbert-base-multilingual-cased-toxicity"
|
| 21 |
+
elif (option == "XLM-RoBERTa"):
|
| 22 |
tokenizerPath = "unitary/multilingual-toxic-xlm-roberta"
|
| 23 |
modelPath = "unitary/multilingual-toxic-xlm-roberta"
|
| 24 |
+
else:
|
| 25 |
tokenizerPath = "s-nlp/roberta_toxicity_classifier"
|
| 26 |
modelPath = "s-nlp/roberta_toxicity_classifier"
|
| 27 |
+
|
| 28 |
tokenizer = AutoTokenizer.from_pretrained(tokenizerPath)
|
| 29 |
model = AutoModelForSequenceClassification.from_pretrained(modelPath)
|
| 30 |
|