hcy5561 commited on
Commit
62b43fd
·
verified ·
1 Parent(s): c5a7534

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Gradio-App-for-NER.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/18duqjwAF3DkX1CsVvr0mc0T763VCd5Q4
8
+
9
+ <a href="https://colab.research.google.com/github/TirendazAcademy/Hugging-Face-Tutorials/blob/main/Gradio_App_for_Ner.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
10
+
11
+ # Gradio Demo: ner_pipeline
12
+ """
13
+
14
+ from transformers import pipeline
15
+
16
+ import gradio as gr
17
+
18
+ ner_pipeline = pipeline("ner", model = "Tirendaz/roberta-base-NER")
19
+
20
+ examples = [
21
+ "My name is Tim and I live in California.",
22
+ "Ich arbeite bei Google in Berlin",
23
+ "Ali, Ankara'lı mı?"
24
+ ]
25
+
26
+ def ner(text):
27
+ output = ner_pipeline(text, aggregation_strategy="simple")
28
+ return {"text": text, "entities": output}
29
+
30
+ demo = gr.Interface(ner,
31
+ gr.Textbox(placeholder="Enter sentence here..."),
32
+ gr.HighlightedText(),
33
+ examples=examples)
34
+
35
+ demo.launch(inline=False, share=True)