Spaces:
Sleeping
Sleeping
Update streamlit_app.py
Browse files- streamlit_app.py +11 -4
streamlit_app.py
CHANGED
|
@@ -6,7 +6,7 @@ from transformers import pipeline
|
|
| 6 |
st.title("News App - Created by Group 09")
|
| 7 |
|
| 8 |
#creating the sub heading
|
| 9 |
-
st.write("## Welcome! In this app users may find the below features")
|
| 10 |
|
| 11 |
#creating the content included in the page
|
| 12 |
st.write("The users can work with uploaded using the Classification page which includes")
|
|
@@ -22,8 +22,10 @@ st.write("""
|
|
| 22 |
- Key-Word recognition
|
| 23 |
""")
|
| 24 |
|
| 25 |
-
|
|
|
|
| 26 |
|
|
|
|
| 27 |
@st.cache_resource
|
| 28 |
def load_classifier():
|
| 29 |
return pipeline(
|
|
@@ -32,11 +34,15 @@ def load_classifier():
|
|
| 32 |
truncation=True
|
| 33 |
)
|
| 34 |
|
|
|
|
| 35 |
classifier = load_classifier()
|
| 36 |
|
|
|
|
| 37 |
user_text = st.text_area("Type a sentence below:")
|
| 38 |
|
|
|
|
| 39 |
if st.button("Classify Text"):
|
|
|
|
| 40 |
if not user_text.strip():
|
| 41 |
st.warning("Please enter some text.")
|
| 42 |
else:
|
|
@@ -44,7 +50,8 @@ if st.button("Classify Text"):
|
|
| 44 |
result = classifier(user_text)
|
| 45 |
|
| 46 |
st.success("Classification complete.")
|
| 47 |
-
|
|
|
|
| 48 |
|
| 49 |
if "score" in result[0]:
|
| 50 |
-
st.write("### Confidence",round(result[0]["score"], 4))
|
|
|
|
| 6 |
st.title("News App - Created by Group 09")
|
| 7 |
|
| 8 |
#creating the sub heading
|
| 9 |
+
st.write("### Welcome! In this app users may find the below features")
|
| 10 |
|
| 11 |
#creating the content included in the page
|
| 12 |
st.write("The users can work with uploaded using the Classification page which includes")
|
|
|
|
| 22 |
- Key-Word recognition
|
| 23 |
""")
|
| 24 |
|
| 25 |
+
#creating a test
|
| 26 |
+
st.write(" ### For a quick test to see how the model classifies,")
|
| 27 |
|
| 28 |
+
#calling and loading the fine tuned model which is uploaded to the hugging face
|
| 29 |
@st.cache_resource
|
| 30 |
def load_classifier():
|
| 31 |
return pipeline(
|
|
|
|
| 34 |
truncation=True
|
| 35 |
)
|
| 36 |
|
| 37 |
+
#calling the model which is now loaded in using a simple variable
|
| 38 |
classifier = load_classifier()
|
| 39 |
|
| 40 |
+
#the user text
|
| 41 |
user_text = st.text_area("Type a sentence below:")
|
| 42 |
|
| 43 |
+
#running the user text through the model to get the output
|
| 44 |
if st.button("Classify Text"):
|
| 45 |
+
#if no proper text
|
| 46 |
if not user_text.strip():
|
| 47 |
st.warning("Please enter some text.")
|
| 48 |
else:
|
|
|
|
| 50 |
result = classifier(user_text)
|
| 51 |
|
| 52 |
st.success("Classification complete.")
|
| 53 |
+
#giving the outputs
|
| 54 |
+
st.write("#### Prediction", result[0]["label"])
|
| 55 |
|
| 56 |
if "score" in result[0]:
|
| 57 |
+
st.write("#### Confidence",round(result[0]["score"], 4))
|