File size: 699 Bytes
bcb314a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
from transformers import pipeline


def main():
    st.title("Working AI Models")
    st.write("Based on your successful test")

    # Используем ту же модель, что работала в тесте
    text = st.text_area("Text to analyze:", "I love this product!")

    if st.button("Get Sentiment"):
        try:
            classifier = pipeline("sentiment-analysis")
            result = classifier(text)[0]
            st.write(f"**Label:** {result['label']}")
            st.write(f"**Score:** {result['score']:.4f}")
            st.balloons()
        except Exception as e:
            st.error(f"Error: {e}")


if __name__ == "__main__":
    main()