test_streamlit / app.py
JB007's picture
Update app.py
b4a770c
raw
history blame contribute delete
883 Bytes
import streamlit as st
from transformers import pipeline
st.set_page_config(page_title="My Streamlit Webpage", page_icon=":tada:", layout="wide")
st.subheader("Subheader text comes here :wave:")
st.title("Getting familiar with Huggingface spaces")
st.write(
"i am passionate about finding ways to leverage ML."
)
form = st.form(key='sentiment-form')
user_input = form.text_area('Enter your text')
submit = form.form_submit_button('Submit')
if submit:
classifier = pipeline("sentiment-analysis")
result = classifier(user_input)[0]
label = result['label']
score = result['score']
if label == 'POSITIVE':
st.success(f'{label} sentiment (score: {score})')
else:
st.error(f'{label} sentiment (score: {score})')
x = st.slider('Select a value')
st.write(x, 'squared is', x * x)
st.write("[Learn More >](https://community.rws.com)")