File size: 362 Bytes
c8daa54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import streamlit as 
from transformers import pipeline 

st.title("Hugging Face Demo")
text = st.text_input("Enter text to analyze")

st.cache_resource
def get_model():
    return pipeline("sentiment-analysis")

model = get_model()
if text:
    result = model(text)
    st.write("Sentiment: ", result[0]["label"])
    st.write("Confidence: ", result[0]["score"])