the-neural-networker
commited on
Commit
•
4939da5
1
Parent(s):
81af590
add files
Browse files- app.py +32 -0
- multi-lingual-language-recognition.ipynb +0 -0
- requirements.txt +6 -0
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
ner_pipeline = pipeline("token-classification", model="the-neural-networker/xlm-roberta-base-finetuned-panx-all")
|
6 |
+
|
7 |
+
examples = [
|
8 |
+
"Does Chicago have any stores and does Joe live here?",
|
9 |
+
]
|
10 |
+
|
11 |
+
def ner(text):
|
12 |
+
output = ner_pipeline(text)
|
13 |
+
return {"text": text, "entities": output}
|
14 |
+
|
15 |
+
|
16 |
+
if __name__ == "__main__":
|
17 |
+
# define app features and run
|
18 |
+
title = "Multilingual Language Recognition Demo"
|
19 |
+
description = "<p style='text-align: center'>Gradio demo for a Multilingual Language Recognition model, viz., XLM-RoBERTa finetuned on the XTREME dataset's English, Hindi, Telugu, and Tamil languages. To use it, type your text, or click one of the examples to load them. Since this demo is run on CPU only, please allow additional time for processing. </p>"
|
20 |
+
article = "<p style='text-align: center'><a href='https://github.com/the-neural-networker/multi-lingual-language-recognition'>Github Repo</a></p>"
|
21 |
+
css = "#0 {object-fit: contain;} #1 {object-fit: contain;}"
|
22 |
+
demo = gr.Interface(fn=ner,
|
23 |
+
title=title,
|
24 |
+
description=description,
|
25 |
+
article=article,
|
26 |
+
inputs=gr.Textbox(placeholder="Enter sentence (English, Hindi, Telugu, Tamil) here..."),
|
27 |
+
outputs=gr.HighlightedText(),
|
28 |
+
css=css,
|
29 |
+
examples=examples,
|
30 |
+
cache_examples=True,
|
31 |
+
allow_flagging='never')
|
32 |
+
demo.launch()
|
multi-lingual-language-recognition.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|
3 |
+
tokenizers
|
4 |
+
datasets
|
5 |
+
gradio
|
6 |
+
jupyter
|