Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
ner_pipeline = pipeline(task='ner', model='cwchang/ner_model', device=-1)
|
| 5 |
+
|
| 6 |
+
def ner(text):
|
| 7 |
+
output = ner_pipeline(text, aggregation_strategy="simple")
|
| 8 |
+
return {"text": text, "entities": output}
|
| 9 |
+
|
| 10 |
+
demo = gr.Interface(
|
| 11 |
+
fn=ner,
|
| 12 |
+
inputs=gr.Textbox(placeholder="Please enter a sentence here..."),
|
| 13 |
+
outputs=gr.HighlightedText(),
|
| 14 |
+
examples=[["Emily Johnson will attend a United Nations meeting in New York on December 5, 2023."],
|
| 15 |
+
["Microsoft plans to launch its new tech product in Tokyo at the beginning of 2024."],
|
| 16 |
+
["Professor Michael Brown from the University of Toronto will present his latest research on climate change."],
|
| 17 |
+
["The famous Christ the Redeemer statue in Rio de Janeiro, Brazil, is scheduled for renovation in July 2023."],
|
| 18 |
+
["Maria Fernandez will open a new art gallery in Paris in June 2023."],
|
| 19 |
+
["The 2023 World Economic Forum is set to take place in Davos, Switzerland, expected to attract numerous international leaders."],
|
| 20 |
+
["Japanese scientist Ichiro Tanaka discovered a new renewable energy technology at the University of Tokyo."],
|
| 21 |
+
["The International Red Cross will initiate a humanitarian aid project in Nairobi, Kenya, in May 2023."],
|
| 22 |
+
["The Sydney Opera House in Australia will host a special concert during Christmas 2023."],
|
| 23 |
+
["The history museum in Berlin, Germany, will organize a World War II exhibition in January 2024."],]
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
demo.launch(debug=True)
|