Text Classification
Transformers
PyTorch
TensorBoard
Safetensors
English
roberta
text-embeddings-inference
Instructions to use smeintadmin/image_intents with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use smeintadmin/image_intents with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="smeintadmin/image_intents")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("smeintadmin/image_intents") model = AutoModelForSequenceClassification.from_pretrained("smeintadmin/image_intents", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 973 Bytes
1ae8986 | 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 | import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
MODEL_DIR = "img_intents_model"
TOKENIZER_NAME = "./results"
# Load the trained model
model = AutoModelForSequenceClassification.from_pretrained(MODEL_DIR)
# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained(TOKENIZER_NAME)
while True:
# Get the input from the command line
input_text = input("Enter a message to classify (or 'q' to quit): ")
if input_text.lower() == 'q':
break
# Encode the input and convert it to a torch tensor
inputs = tokenizer.encode_plus(input_text, return_tensors='pt')
# Get the model's prediction
outputs = model(**inputs)
# Get the predicted class from the model's output
predicted_class = torch.argmax(outputs.logits).item()
if predicted_class == 1:
print("The message is predicted as an image intent.")
else:
print("The message is not predicted as an image intent.")
|