File size: 692 Bytes
988a1f0 1c55f2c 6dad9e3 49d2fed 6dad9e3 f7ee327 3b784aa 6dad9e3 988a1f0 ae28ea8 988a1f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
id2label = {0: "Negative", 1: "Positive"}
label2id = {"Negative":0, "Positive":1}
# Load the tokenizer and model
tokenizer = AutoTokenizer.from_pretrained('distilbert/distilbert-base-uncased', add_prefix_space=True)
model = AutoModelForSequenceClassification.from_pretrained('AmirRghp/distilbert-base-uncasedimdb-text-classification')
# Create the pipeline
classifier = pipeline('text-classification', model=model, tokenizer=tokenizer)
def classify_text(text):
result = classifier(text)
return result
gr.Interface(fn=classify_text, inputs="text", outputs="json").launch()
|