Spaces:
Runtime error
Runtime error
import os | |
import gradio as gr | |
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification | |
HF_TOKEN = os.environ.get('HF_TOKEN') | |
model_checkpoint = "besijar/dspa_review_classification" | |
tokeniser = AutoTokenizer.from_pretrained(model_checkpoint, use_auth_token=HF_TOKEN) | |
model = TFAutoModelForSequenceClassification.from_pretrained(model_checkpoint, use_auth_token=HF_TOKEN) | |
example_review = "Tully's House Blend is the perfect K-Cup for me. Sure, I occasionally enjoy the special flavors.....Mocha, Italian roast, French vanilla, but my favorite 'go-to'coffee is House Blend. Wakes me up in the morning with it's coffee house full hearty taste." | |
def review_classify(review): | |
review = tokeniser.encode(review) | |
review = model.predict([review]) | |
return int(review.logits.argmax()) | |
iface = gr.Interface(review_classify, | |
title="Review Classification using DistilRoBERTa", | |
inputs=[gr.Text(label="Review")], | |
outputs=[gr.Number(label="Rating", precision=0)], | |
examples=[example_review]) | |
iface.launch() |