slliac commited on
Commit
53f11d4
·
verified ·
1 Parent(s): 110eae8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -23
app.py CHANGED
@@ -1,30 +1,26 @@
1
  import streamlit as st
2
- from transformers import pipeline
3
 
4
- # Load the text classification model pipeline
5
- classifier = pipeline("text-classification",model='slliac/my_model', return_all_scores=True)
6
 
7
- # Streamlit application title
8
- st.title("Text Classification for you")
9
- st.write("Classification for 6 emotions: sadness, joy, love, anger, fear, surprise")
10
 
11
- # Text input for user to enter the text to classify
12
- text = st.text_area("Enter the text to classify", "")
 
13
 
14
- # Perform text classification when the user clicks the "Classify" button
15
- if st.button("Classify"):
16
- # Perform text classification on the input text
17
- results = classifier(text)[0]
18
 
19
- # Display the classification result
20
- max_score = float('-inf')
21
- max_label = ''
 
22
 
23
- for result in results:
24
- if result['score'] > max_score:
25
- max_score = result['score']
26
- max_label = result['label']
27
-
28
- st.write("Text:", text)
29
- st.write("Label:", max_label)
30
- st.write("Score:", max_score)
 
1
  import streamlit as st
 
2
 
3
+ # Title
4
+ st.title("Streamlit Demo: Buttons, Slider, Image & File Uploader")
5
 
6
+ # Button Demo
7
+ if st.button("Click Me!"):
8
+ st.write("Button Clicked!")
9
 
10
+ # Slider Demo
11
+ slider_value = st.slider("Select a value", min_value=0, max_value=100, value=50)
12
+ st.write(f"Slider value: {slider_value}")
13
 
14
+ # Text Input Demo
15
+ user_text = st.text_input("Enter some text")
16
+ st.write(f"You entered: {user_text}")
 
17
 
18
+ # Image Uploader Demo
19
+ uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "png", "jpeg"])
20
+ if uploaded_image is not None:
21
+ st.image(uploaded_image, caption="Uploaded Image", use_container_width=True)
22
 
23
+ # File Uploader Demo
24
+ uploaded_file = st.file_uploader("Upload a File", type=["txt", "csv", "pdf"])
25
+ if uploaded_file is not None:
26
+ st.write("Uploaded File Name:", uploaded_file.name)