Sentiment Analysis

Runnable examples for the frozen Gradio Lite 5.45.0 browser runtime.

Download a Transformers.js sentiment model and run it through a Python pipeline.

This coding playground downloads a sentiment-analysis model after the Python package starts. Click Run, then edit an example sentence. The first run requires network access and can take longer while the model is downloaded and cached.

Code
import gradio as gr
from transformers_js_py import pipeline

pipe = await pipeline('sentiment-analysis')

demo = gr.Interface.from_pipeline(
    pipe,
    flagging_mode="never",
    live=True,
    examples=[
      ["🟢 Quarto + Gradio is a great match"],
      ["🔴 It would be a shame if this integration didn't work"],
    ],
)

demo.launch()
transformers-js-py==0.19.10 import gradio as gr from transformers_js_py import pipeline pipe = await pipeline('sentiment-analysis') demo = gr.Interface.from_pipeline( pipe, flagging_mode="never", live=True, examples=[ ["🟢 Quarto + Gradio is a great match"], ["🔴 It would be a shame if this integration didn't work"], ], ) demo.launch()