Spaces:
Runtime error
Runtime error
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() | |