Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,16 +4,39 @@ import streamlit as st
|
|
| 4 |
from transformers import pipeline
|
| 5 |
import datetime
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# File upload
|
| 8 |
uploaded_file = st.file_uploader("Upload your expense CSV file", type=["csv"])
|
| 9 |
if uploaded_file:
|
| 10 |
df = pd.read_csv(uploaded_file)
|
| 11 |
|
| 12 |
-
# Display
|
|
|
|
| 13 |
st.write(df.head())
|
| 14 |
|
|
|
|
|
|
|
|
|
|
| 15 |
# Initialize Hugging Face model for zero-shot classification
|
| 16 |
-
classifier = pipeline('zero-shot-classification', model='
|
| 17 |
categories = ["Groceries", "Rent", "Utilities", "Entertainment", "Dining", "Transportation"]
|
| 18 |
|
| 19 |
# Function to categorize
|
|
|
|
| 4 |
from transformers import pipeline
|
| 5 |
import datetime
|
| 6 |
|
| 7 |
+
# Function to add background image to the app
|
| 8 |
+
def add_bg_from_url(image_url):
|
| 9 |
+
st.markdown(
|
| 10 |
+
f"""
|
| 11 |
+
<style>
|
| 12 |
+
.stApp {{
|
| 13 |
+
background-image: url({image_url});
|
| 14 |
+
background-size: cover;
|
| 15 |
+
background-position: center center;
|
| 16 |
+
background-repeat: no-repeat;
|
| 17 |
+
}}
|
| 18 |
+
</style>
|
| 19 |
+
""",
|
| 20 |
+
unsafe_allow_html=True
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Set background image (it will remain even after file upload)
|
| 24 |
+
add_bg_from_url('https://huggingface.co/spaces/engralimalik/Smart-Expense-Tracker/resolve/main/top-view-finance-business-elements.jpg')
|
| 25 |
+
|
| 26 |
# File upload
|
| 27 |
uploaded_file = st.file_uploader("Upload your expense CSV file", type=["csv"])
|
| 28 |
if uploaded_file:
|
| 29 |
df = pd.read_csv(uploaded_file)
|
| 30 |
|
| 31 |
+
# Display first few rows to the user for format verification
|
| 32 |
+
st.write("Here are the first few entries in your file for format verification:")
|
| 33 |
st.write(df.head())
|
| 34 |
|
| 35 |
+
# Ensure 'Amount' is numeric
|
| 36 |
+
df['Amount'] = pd.to_numeric(df['Amount'], errors='coerce')
|
| 37 |
+
|
| 38 |
# Initialize Hugging Face model for zero-shot classification
|
| 39 |
+
classifier = pipeline('zero-shot-classification', model='roberta-large-mnli')
|
| 40 |
categories = ["Groceries", "Rent", "Utilities", "Entertainment", "Dining", "Transportation"]
|
| 41 |
|
| 42 |
# Function to categorize
|