Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,11 @@
|
|
| 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 sentiment analysis model
|
| 9 |
classifier = pipeline("sentiment-analysis", model="Suphawan/website_classification")
|
| 10 |
|
| 11 |
def main():
|
| 12 |
-
st.title("Website
|
| 13 |
|
| 14 |
with st.form("text_field"):
|
| 15 |
text = st.text_area('Enter some text:')
|
|
@@ -17,17 +13,13 @@ def main():
|
|
| 17 |
clicked = st.form_submit_button("Submit text")
|
| 18 |
|
| 19 |
if clicked:
|
| 20 |
-
# Perform
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
confidence =
|
| 24 |
-
|
| 25 |
-
# Compute sentence embeddings
|
| 26 |
-
sentence_embeddings = model.encode([text])
|
| 27 |
|
| 28 |
-
st.write("
|
| 29 |
st.write("Confidence:", confidence)
|
| 30 |
-
st.write("Sentence Embeddings:", sentence_embeddings)
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
| 33 |
main()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# Load the sentiment analysis model
|
| 5 |
classifier = pipeline("sentiment-analysis", model="Suphawan/website_classification")
|
| 6 |
|
| 7 |
def main():
|
| 8 |
+
st.title("Website Classification")
|
| 9 |
|
| 10 |
with st.form("text_field"):
|
| 11 |
text = st.text_area('Enter some text:')
|
|
|
|
| 13 |
clicked = st.form_submit_button("Submit text")
|
| 14 |
|
| 15 |
if clicked:
|
| 16 |
+
# Perform website classification
|
| 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()
|