CoolFace
Apppublic

Thitikarn/Language_modeling

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py32 linesDownload Raw Back to root
1import streamlit as st2from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline3 4tokenizer = AutoTokenizer.from_pretrained("Thitikarn/finetuned_yelp")5model = AutoModelForSequenceClassification.from_pretrained("Thitikarn/finetuned_yelp")6 7nlp = pipeline("sentiment-analysis", model= model, tokenizer= tokenizer )8 9st.title("Language_modeling_text")10text_input = st.text_input('text input here')11 12if text_input:13    result = nlp(text_input)14    label_id = result[0]["label"]15    value_score = result[0]["score"]16 17    # แปลง label_id เป็นคำอธิบายที่คุณต้องการ18    if label_id == "LABEL_0":19        sentiment_label = "very bad"20    elif label_id == "LABEL_1":21        sentiment_label = "bad"22    elif label_id == "LABEL_2":23        sentiment_label = "neutral"24    elif label_id == "LABEL_3":25        sentiment_label = "good"26    elif label_id == "LABEL_4":27        sentiment_label = "very good"28    else:29        sentiment_label = "ไม่พบค่าที่ต้องการ"30 31    st.write(sentiment_label)32    st.write(value_score)