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!")