Spaces:
Runtime error
Runtime error
Download app.py from bcokdilli/NER-App-Demo: direct link, hf CLI and curl.
- Browser
- Download file 809 Bytes
-
https://huggingface.co/spaces/bcokdilli/NER-App-Demo/resolve/main/app.py
- Command line
-
hf download hf://spaces/bcokdilli/NER-App-Demo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/bcokdilli/NER-App-Demo/resolve/main/app.py
809 Bytes
| # -*- coding: utf-8 -*- | |
| """Gradio_NER_App.ipynb | |
| Automatically generated by Colab. | |
| Original file is located at | |
| https://colab.research.google.com/drive/1dt0Kqtqx219rAx4P9rzC_IToFqgVD1K0 | |
| """ | |
| # !pip install -q transformers | |
| from transformers import pipeline | |
| ner_pipeline = pipeline("ner", model="bcokdilli/multilingual-xlm-roberta-for-ner") | |
| def ner(text): | |
| output = ner_pipeline(text, aggregation_strategy = "simple") | |
| return {"text": text, "entities": output} | |
| # !pip install -q gradio | |
| import gradio as gr | |
| examples = [ | |
| "My name is Elon and I live in Texas", | |
| "Ich arbeite bei Google in Berlin", | |
| "Bahadır, Bursa'lı mı?" | |
| ] | |
| demo = gr.Interface( | |
| ner, | |
| gr.Textbox(placeholder="Enter sentence here..."), | |
| gr.HighlightedText(), | |
| examples=examples | |
| ) | |
| demo.launch(share=True) | |