tugot17 commited on
Commit
c1e91ac
1 Parent(s): f59242c

Upload gradio.py

Browse files
Files changed (1) hide show
  1. gradio.py +20 -0
gradio.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline("text-classification", model="tugot17/my-awesome-model", tokenizer=tokenizer)
5
+ def predict(text):
6
+ output = {}
7
+
8
+ for result in classifier(text, top_k=None):
9
+ output[result["label"]] = result["score"]
10
+
11
+ return output
12
+
13
+ iface = gr.Interface(
14
+ fn=predict,
15
+ inputs='text',
16
+ outputs=gr.Label(num_top_classes=2),
17
+ 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"]]
18
+ )
19
+
20
+ iface.launch()