Spaces:
Build error
Build error
Download app.py from jonathanbsanders/gpt-neox: direct link, hf CLI and curl.
- Browser
- Download file 698 Bytes
-
https://huggingface.co/spaces/jonathanbsanders/gpt-neox/resolve/main/app.py
- Command line
-
hf download hf://spaces/jonathanbsanders/gpt-neox/app.py
-
curl -L -o app.py https://huggingface.co/spaces/jonathanbsanders/gpt-neox/resolve/main/app.py
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() |