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