bnsapa commited on
Commit
1c4697d
1 Parent(s): cf204c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -20
app.py CHANGED
@@ -1,21 +1,23 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
- import os
4
- from dotenv import load_dotenv
5
- load_dotenv()
6
-
7
- share = os.getenv("SHARE", False)
8
-
9
- pipe = pipeline("token-classification", model="bnsapa/cybersecurity-ner")
10
- def tag(input):
11
- k = pipe(input)
12
- return f"{k}"
13
-
14
- iface = gr.Interface(fn=tag, inputs="text", outputs="text", title="Cybersecurity NER", description="Named Entity Recognition for Cybersecurity")
15
-
16
- if __name__ == "__main__":
17
- if share:
18
- server = "0.0.0.0"
19
- else:
20
- server = "127.0.0.1"
 
 
21
  iface.launch(server_name = server)
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ import os
4
+ from dotenv import load_dotenv
5
+ load_dotenv()
6
+
7
+ share = os.getenv("SHARE", False)
8
+
9
+ pipe = pipeline("token-classification", model="bnsapa/cybersecurity-ner")
10
+ def tag(input):
11
+ k = pipe(input)
12
+ for i in k:
13
+ input = input.replace(i["word"], i["word"] + "[" + i["entity"] + " Score: " + str(i["score"]) +"]")
14
+ return input
15
+
16
+ iface = gr.Interface(fn=tag, inputs="text", outputs="text", title="Cybersecurity NER", description="Named Entity Recognition for Cybersecurity")
17
+
18
+ if __name__ == "__main__":
19
+ if share:
20
+ server = "0.0.0.0"
21
+ else:
22
+ server = "127.0.0.1"
23
  iface.launch(server_name = server)