Commit
·
6514fd7
1
Parent(s):
f5fa403
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model_checkpoint = "MuntasirHossain/bert-finetuned-ner"
|
5 |
+
|
6 |
+
model = pipeline("token-classification", model=model_checkpoint, aggregation_strategy="simple")
|
7 |
+
|
8 |
+
|
9 |
+
def predict(prompt):
|
10 |
+
completion = model(prompt)
|
11 |
+
return completion
|
12 |
+
|
13 |
+
description = "This AI model is trained to identify and classify named entities in unstructured text."
|
14 |
+
title = "Named Entity Recognition"
|
15 |
+
theme = "grass"
|
16 |
+
examples=[["Mount Everest is Earth's highest mountain, located in the Mahalangur Himal sub-range of the Himalayas. The China-Nepal border runs across it."]]
|
17 |
+
|
18 |
+
gr.Interface(fn=predict,
|
19 |
+
inputs="textbox",
|
20 |
+
outputs="text",
|
21 |
+
title=title,
|
22 |
+
theme = theme,
|
23 |
+
description=description,
|
24 |
+
examples=examples,
|
25 |
+
).launch()
|