Spaces:
Runtime error
Runtime error
tirendazakademi
commited on
Commit
•
72faba1
1
Parent(s):
76d6678
added app files
Browse files- app.py +22 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
ner_pipeline = pipeline("ner", model = "Tirendaz/roberta-base-NER")
|
6 |
+
|
7 |
+
examples = [
|
8 |
+
"My name is Tim and I live in California.",
|
9 |
+
"Ich arbeite bei Google in Berlin",
|
10 |
+
"Ali, Ankara'lı mı?"
|
11 |
+
]
|
12 |
+
|
13 |
+
def ner(text):
|
14 |
+
output = ner_pipeline(text, aggregation_strategy="simple")
|
15 |
+
return {"text": text, "entities": output}
|
16 |
+
|
17 |
+
demo = gr.Interface(ner,
|
18 |
+
gr.Textbox(placeholder="Enter sentence here..."),
|
19 |
+
gr.HighlightedText(),
|
20 |
+
examples=examples)
|
21 |
+
|
22 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers==4.30.2
|
2 |
+
gradio==3.0
|
3 |
+
torch==2.0.0
|