Spaces:
Runtime error
Runtime error
Add Cybersecurity NER functionality using Gradio
Browse files
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)
|