TURNA / apps /sentiment.py
yirmibesogluz's picture
Removed S2S NLU NLG models
9295e45
raw
history blame
1.32 kB
import requests
import streamlit as st
import time
from transformers import pipeline
import os
from .utils import query
HF_AUTH_TOKEN = os.getenv('HF_AUTH_TOKEN')
headers = {"Authorization": f"Bearer {HF_AUTH_TOKEN}"}
def write():
st.markdown("# Sentiment Classification")
st.sidebar.header("Sentiment Classification")
st.write(
"""Here, you can perform sentiment classification using the fine-tuned TURNA classification models. """
)
# Sidebar
# Taken from https://huggingface.co/spaces/flax-community/spanish-gpt2/blob/main/app.py
st.sidebar.subheader("Configurable parameters")
model_name = st.sidebar.selectbox(
"Model Selector",
options=[
"turna_classification_17bintweet_sentiment",
"turna_classification_tr_product_reviews",
],
index=0,
)
"""max_new_tokens = st.sidebar.number_input(
"Maximum length",
min_value=0,
max_value=20,
value=20,
help="The maximum length of the sequence to be generated.",
)"""
input_text = st.text_area(label='Enter a text: ', height=100,
value="sonunda bugün kurtuldum senden")
url = ("https://api-inference.huggingface.co/models/boun-tabi-LMG/" + model_name.lower())
params = {"max_new_tokens": 4 }
if st.button("Generate"):
with st.spinner('Generating...'):
output = query(input_text, url, params)
st.success(output)