nppmatt commited on
Commit
9a8f76b
1 Parent(s): ee88837
Files changed (1) hide show
  1. app.py +7 -5
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 option:
14
- case RoBERTa:
 
15
  tokenizerPath = "s-nlp/roberta_toxicity_classifier"
16
  modelPath = "s-nlp/roberta_toxicity_classifier"
17
- case DistilBERT:
18
  tokenizerPath = "citizenlab/distilbert-base-multilingual-cased-toxicity"
19
  modelPath = "citizenlab/distilbert-base-multilingual-cased-toxicity"
20
- case XLM-RoBERTa:
21
  tokenizerPath = "unitary/multilingual-toxic-xlm-roberta"
22
  modelPath = "unitary/multilingual-toxic-xlm-roberta"
23
- case _:
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