Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from transformers import pipeline | |
| from sentence_transformers import SentenceTransformer | |
| # Load the Sentence Transformers model | |
| model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') | |
| # Load the sentiment analysis model | |
| classifier = pipeline("sentiment-analysis", model="Suphawan/website_classification") | |
| def main(): | |
| st.title("Website classification") | |
| with st.form("text_field"): | |
| text = st.text_area('Enter some text:') | |
| # clicked will be True only when the button is clicked | |
| clicked = st.form_submit_button("Submit text") | |
| if clicked: | |
| # Perform sentiment analysis | |
| sentiment_results = classifier([text]) | |
| sentiment = sentiment_results[0]['label'] | |
| confidence = sentiment_results[0]['score'] | |
| # Compute sentence embeddings | |
| sentence_embeddings = model.encode([text]) | |
| st.write("Sentiment:", sentiment) | |
| st.write("Confidence:", confidence) | |
| st.write("Sentence Embeddings:", sentence_embeddings) | |
| if __name__ == "__main__": | |
| main() | |