import gradio as gr from transformers import AutoTokenizer, AutoModelForSequenceClassification # Load the model and tokenizer tokenizer = AutoTokenizer.from_pretrained("padmajabfrl/Gender-Classification") model = AutoModelForSequenceClassification.from_pretrained("padmajabfrl/Gender-Classification") # Function to predict gender def predict_gender(name): inputs = tokenizer(name, return_tensors="pt") outputs = model(**inputs) predictions = outputs.logits.argmax(dim=-1) predicted_label = model.config.id2label[predictions.item()] return predicted_label # Create a Gradio interface with gr.Blocks() as demo: gr.Markdown("

Kaleida Gender Prediction Transformer

") gr.Markdown("

Tops Infosolution 🤝 Kaleida

") with gr.Row(): with gr.Column(): name_input = gr.Textbox(label="Enter a Name", placeholder="Type a name here...", lines=1) classify_button = gr.Button("Predict Gender") with gr.Column(): output_label = gr.Label(label="Predicted Gender") classify_button.click(predict_gender, inputs=name_input, outputs=output_label) # Launch the app demo.launch()