Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
|
| 4 |
-
# Load the
|
|
|
|
|
|
|
|
|
|
| 5 |
classifier = pipeline("sentiment-analysis", model="Suphawan/website_classification")
|
| 6 |
|
| 7 |
def main():
|
|
@@ -17,9 +21,13 @@ def main():
|
|
| 17 |
classification_results = classifier([text])
|
| 18 |
category = classification_results[0]['label']
|
| 19 |
confidence = classification_results[0]['score']
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
st.write("Category:", category)
|
| 22 |
st.write("Confidence:", confidence)
|
|
|
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
main()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
+
from sentence_transformers import SentenceTransformer
|
| 4 |
|
| 5 |
+
# Load the Sentence Transformers model
|
| 6 |
+
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
| 7 |
+
|
| 8 |
+
# Load the website classification model (replace 'Suphawan/website_classification' with your actual model)
|
| 9 |
classifier = pipeline("sentiment-analysis", model="Suphawan/website_classification")
|
| 10 |
|
| 11 |
def main():
|
|
|
|
| 21 |
classification_results = classifier([text])
|
| 22 |
category = classification_results[0]['label']
|
| 23 |
confidence = classification_results[0]['score']
|
| 24 |
+
|
| 25 |
+
# Compute sentence embeddings
|
| 26 |
+
sentence_embeddings = model.encode([text])
|
| 27 |
|
| 28 |
st.write("Category:", category)
|
| 29 |
st.write("Confidence:", confidence)
|
| 30 |
+
st.write("Sentence Embeddings:", sentence_embeddings)
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
| 33 |
main()
|