alyxx commited on
Commit
2f09011
·
1 Parent(s): 0dc48fb

added file

Browse files
Files changed (2) hide show
  1. app.py +38 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+
5
+
6
+ ner = pipeline("ner",
7
+ model='kaiku03/bert-base-NER-finetuned_custom_complain_dataset_NER9',
8
+ # grouped_entities=True,
9
+ aggregation_strategy="simple"
10
+ )
11
+
12
+
13
+ # function for the gradio app
14
+ def fn_ner(prompt):
15
+ return ner(prompt)
16
+
17
+
18
+ # gradio app
19
+ # Define example inputs and outputs
20
+ examples = [
21
+ "Subject: Defective Date: 08-13-2023 Product: XXX speaker Location: 456 Sound Avenue, Audiotown",
22
+ "Subject: Dirty Date: 08-10-2023 Product: UVW Television Location: 567 Willow Lane, Mediatown",
23
+ "Subject: Missing Parts Date: 08-10-2023 Product: XXX Furniture Set Location: 1800 Antipolo Rizal Furnitown",
24
+ ]
25
+
26
+ iface = gr.Interface(
27
+ fn=fn_ner,
28
+ inputs='text',
29
+ outputs=gr.Label(label="Name Entity Recognition"),
30
+ examples=[
31
+ [ex] for ex in examples
32
+ ],
33
+ title='English to Tagalog translator',
34
+ description='This demo performs language translation from English to Tagalog.',
35
+ article='All done by Kaiku',
36
+ )
37
+
38
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ transformers
2
+ gradio==3.40
3
+ torch
4
+ seqeval
5
+ evaluate