Spaces:
Running
Running
File size: 1,125 Bytes
23c859c 60a3ae1 56f2045 fde3e5f 56f2045 23c859c 56f2045 fde3e5f 56f2045 60a3ae1 fde3e5f 56f2045 23c859c 60a3ae1 23c859c |
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 33 34 35 36 |
from gradio import components as gc
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# Load model and tokenizer
model_name = "Canstralian/CySec_Known_Exploit_Analyzer"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Define the function for text input processing
def greet(text):
# Tokenize and process the input text
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
# Extract the label with the highest score
predicted_label = outputs.logits.argmax().item()
return f"Greeting, {text}! Predicted label: {predicted_label}"
# Create the interface
iface = gr.Interface(
fn=greet,
inputs="text",
outputs="text",
title="Greeting App",
description="Ask a user for their name and greet them."
)
# Optional: define and add a sidebar if needed
# Example sidebar component (replace with your intended content)
sidebar = gr.Textbox(label="Sidebar Info")
iface.add_component(sidebar, side="left")
# Launch the Gradio app
iface.launch()
|