Spaces:
Build error

gpt-neox / app.py
light-cmd
fasdf
7aa4b28
Raw History Blame Contribute Delete
698 Bytes
import gradio as gr
import transformers
from transformers import BertTokenizer
# Load a pre-trained model
model = transformers.AutoModelForSequenceClassification.from_pretrained("bert-base-cased-finetuned-mrpc")
# Create a function that takes in a text input and returns the model's classification
def classify_text(input_text):
input_ids = model.tokenizer.encode(input_text, max_length=512, add_special_tokens=True)
output = model(input_ids)[0]
_, predicted_class = output.max(1)
return predicted_class
# Create a Gradio interface for the model
iface = gr.Interface(fn=classify_text, inputs="text", outputs="label", title="Text Classifier")
# Start the interface
iface.launch()