File size: 705 Bytes
56e3fda
ac54b7e
 
56e3fda
ac54b7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50047df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
from transformers import BertTokenizer, BertForSequenceClassification
from transformers import pipeline

urlbert = BertForSequenceClassification.from_pretrained('elftsdmr/malware-url-detect',num_labels=2)
tokenizer = BertTokenizer.from_pretrained('elftsdmr/malware-url-detect')

url_classifier = pipeline("text-classification", model=urlbert, tokenizer=tokenizer)





def text_to_url(text):
    return url_classifier(text)[0]["label"]


demo = gr.Blocks(theme=gr.themes.Soft())

with demo:
   
    text = gr.Textbox()
    label = gr.Label()

  
    b2 = gr.Button("Classify URL")

   
    b2.click(text_to_url, inputs=text, outputs=label)

if __name__ == "__main__":
    demo.launch()