Mhammad Ibrahim commited on
Commit
5667b16
·
1 Parent(s): d394f6d

Add application file

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -1,7 +1,19 @@
 
 
 
 
 
 
 
 
1
  import gradio as gr
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
1
+ # import gradio as gr
2
+
3
+ # def greet(name):
4
+ # return "Hello " + name + "!!"
5
+
6
+ # demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+ # demo.launch()
8
+
9
  import gradio as gr
10
+ from transformers import pipeline
11
+
12
+ # Load model from Hugging Face Hub
13
+ classifier = pipeline("text-classification", model="Mhammad2023/bert-finetuned-ner")
14
 
15
+ def predict(text):
16
+ result = classifier(text)[0]
17
+ return f"{result['label']} ({round(result['score']*100, 2)}%)"
18
 
19
+ gr.Interface(fn=predict, inputs="text", outputs="text", title="Text Classification").launch()