File size: 618 Bytes
f7c8082
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import streamlit as st
from transformers import pipeline
model = pipeline('text-classification', model='distilbert-base-uncased')
def app():
    # Set the title of the app
    st.title("Text Classification with Huggingface")

    # Get user input
    user_input = st.text_input("Enter some text")

    # Classify the text using the Huggingface model
    if user_input:
        result = model(user_input)[0]
        label = result['label']
        score = result['score']

        # Display the result
        st.write(f"Label: {label}")
        st.write(f"Score: {score}")
        
if __name__ == "__main__":
    app()