Gregoryjr commited on
Commit
5d5484f
·
unverified ·
1 Parent(s): 70f481c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -6,7 +6,7 @@ st.write("in this basic demo you can select a model to judge whether or not the
6
  text = "The mail man looks dumb"
7
  st.write(text)
8
 
9
- options = ["zero-shot-classification", "cardiffnlp/twitter-roberta-base-offensive"]
10
  model = st.selectbox("Select a pre-trained model", options)
11
 
12
  con = st.button("Submit")
@@ -24,3 +24,16 @@ if con:
24
  label = result[0]['label']
25
  score = result[0]['score']
26
  st.write(f"Prediction: {label}, Score: {score*100}% chance")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  text = "The mail man looks dumb"
7
  st.write(text)
8
 
9
+ options = ["zero-shot-classification", "cardiffnlp/twitter-roberta-base-offensive", "Greys/milestonemodel"]
10
  model = st.selectbox("Select a pre-trained model", options)
11
 
12
  con = st.button("Submit")
 
24
  label = result[0]['label']
25
  score = result[0]['score']
26
  st.write(f"Prediction: {label}, Score: {score*100}% chance")
27
+
28
+ if model = "Greys/milestonemodel"
29
+
30
+ tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
31
+ model = AutoModelForSequenceClassification.from_pretrained("Greys/milestonemodel")
32
+
33
+ def classify_sentence(sentence):
34
+ inputs = tokenizer(sentence, return_tensors="pt")
35
+ outputs = model(**inputs)
36
+ probs = outputs.logits.softmax(dim=1)
37
+ return probs.detach().numpy()[0]
38
+ probs = classify_sentence(text)
39
+ print(probs)