File size: 1,029 Bytes
67c2f8b
 
5b4941e
5df8da3
7f19bde
67c2f8b
 
 
 
7f19bde
 
67c2f8b
7f19bde
67c2f8b
 
 
 
 
 
7f19bde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import streamlit as st
from transformers import pipeline
import tensorflow
import torch

# Create a sentiment analysis pipeline
pipe = pipeline("sentiment-analysis")

# Streamlit UI
st.title("Sentiment Analysis with Transformers")

sentence = st.text_area("Enter a sentence:")

if st.button("Analyze"):
    if sentence:
        result = pipe(sentence)
        st.write("Sentiment:", result[0]['label'], "with confidence:", result[0]['score'])
    else:
        st.warning("Please enter a sentence.")

# Deployment-specific code
if __name__ == "__main__":
    import hugginface_hub

    commit_message = "Deploying Sentiment Analysis app"
    repo_id = "your-huggingface-username/your-repo-name"  # Replace with your repo details
    branch = "main"  # Replace with your desired branch

    with st.spinner("Deploying to Hugging Face Spaces..."):
        huggingface_hub.deploy(
            repo_id=repo_id,
            branch=branch,
            commit_message=commit_message,
        )

    st.success("Deployment successful!")