File size: 672 Bytes
24866b4
 
e85afcc
24866b4
5cde343
 
24866b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline
from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")

classifier = pipeline("text-classification", model="tugot17/my-awesome-model", tokenizer=tokenizer)
def predict(text):
  output = {}

  for result in classifier(text, top_k=None):
    output[result["label"]] = result["score"]

  return output

iface = gr.Interface(
  fn=predict, 
  inputs='text',
  outputs=gr.Label(num_top_classes=2),
  examples=[["SIX chances to win CASH! From 100 to 20,000 pounds txt> CSH11 and send to 87575. Cost 150p/day, 6days, 16+ TsandCs apply Reply HL 4 info"]]
)

iface.launch()