Spaces:
Sleeping
Sleeping
File size: 598 Bytes
676a921 dad64f0 8242945 676a921 dad64f0 19fe6d3 dad64f0 19fe6d3 dad64f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from transformers import pipeline
import os
token = os.environ.get("HF_TOKEN")
classifier = pipeline(model="Yanni8/star-predictor", token=token)
def predict(text):
labels = classifier(text, top_k=5)
return {label['label']: label['score'] for label in labels}
iface = gr.Interface(
fn=predict,
inputs=gr.Textbox(lines=7, label="Input Text"),
outputs=gr.Label(num_top_classes=3, label="Predicted Star"),
title="Star Predictor",
description="Predict the star rating of a review\n\n Try for example: 'This is a great product!'",
)
iface.launch() |