Maham930 commited on
Commit
a674d84
·
verified ·
1 Parent(s): 09988ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -24
app.py CHANGED
@@ -1,30 +1,31 @@
1
- # sentiment_app.py
2
 
3
  import streamlit as st
4
- from transformers import pipeline
5
 
6
- # Load sentiment analysis pipeline
7
- @st.cache_resource
8
- def load_model():
9
- return pipeline("sentiment-analysis")
10
 
11
- classifier = load_model()
 
 
12
 
13
- # Streamlit UI
14
- st.set_page_config(page_title="Sentiment Classifier", layout="centered")
15
- st.title("🧠 Sentiment Classification App")
16
- st.write("Enter a piece of text, and the model will predict its sentiment.")
17
 
18
- # Text input
19
- text_input = st.text_area("Enter your text here", height=150)
20
-
21
- # Predict button
22
- if st.button("Classify Sentiment"):
23
- if text_input.strip() == "":
24
- st.warning("Please enter some text to analyze.")
25
- else:
26
- with st.spinner("Analyzing..."):
27
- result = classifier(text_input)
28
- label = result[0]['label']
29
- score = result[0]['score']
30
- st.success(f"**Prediction:** {label} ({score:.2f} confidence)")
 
 
 
 
 
1
+ # calculator_app.py
2
 
3
  import streamlit as st
 
4
 
5
+ st.set_page_config(page_title="Simple Calculator", layout="centered")
6
+ st.title("🧮 Simple Calculator")
 
 
7
 
8
+ # User inputs
9
+ num1 = st.number_input("Enter first number:", value=0.0, format="%.2f")
10
+ num2 = st.number_input("Enter second number:", value=0.0, format="%.2f")
11
 
12
+ # Operation selector
13
+ operation = st.selectbox("Select operation:", ("Add", "Subtract", "Multiply", "Divide"))
 
 
14
 
15
+ # Perform calculation
16
+ if st.button("Calculate"):
17
+ if operation == "Add":
18
+ result = num1 + num2
19
+ st.success(f"Result: {result:.2f}")
20
+ elif operation == "Subtract":
21
+ result = num1 - num2
22
+ st.success(f"Result: {result:.2f}")
23
+ elif operation == "Multiply":
24
+ result = num1 * num2
25
+ st.success(f"Result: {result:.2f}")
26
+ elif operation == "Divide":
27
+ if num2 == 0:
28
+ st.error("Error: Division by zero is not allowed.")
29
+ else:
30
+ result = num1 / num2
31
+ st.success(f"Result: {result:.2f}")