Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
server = "
|
|
|
|
|
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)
|