bnsapa commited on
Commit
a3afefa
1 Parent(s): ed95780

Add Cybersecurity NER functionality using Gradio

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)