Skip to content

Commit

Permalink
Changes made
Browse files Browse the repository at this point in the history
  • Loading branch information
SonyShrestha committed Jun 8, 2024
1 parent 11a31f1 commit 6ca2a06
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 31 deletions.
29 changes: 12 additions & 17 deletions Website/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,19 @@ def main():
unsafe_allow_html=True
)

# Custom CSS to remove space between buttons and position logo, footer always at the bottom
# Custom CSS to style buttons, position logo, and footer
st.markdown(
"""
<style>
.stButton button {
margin: 0;
padding: 0px;
.stButton>button {
font-size: 10;
height: 100%;
width: 100%;
font-size: 100px;
white-space: nowrap; // Prevents text from wrapping
overflow: hidden; // Keeps text from overflowing
text-overflow: ellipsis; // Adds an ellipsis if text overflows
}
.stColumn {
display: flex;
justify-content: center;
align-items: center;
padding: 0; // Adjusts padding to reduce space between columns
margin: 0; // Removes margin around columns
white-space: nowrap; /* Prevents text from wrapping */
overflow: hidden; /* Keeps text from overflowing */
text-overflow: ellipsis; /* Adds an ellipsis if text overflows */
margin-bottom: 0; /* Removes space between buttons */
padding: 1; /* Removes padding around buttons */
}
.top-right-logo {
position: absolute;
Expand All @@ -73,11 +67,10 @@ def main():
)

# Create a single row of columns with equal width
cols = st.columns(9) # Creates 8 equally spaced columns
cols = st.columns(8) # Creates 8 equally spaced columns (one less for Home)

# Dictionary to map button names to functions
pages = {
'Home': home,
'OCR': ocr_invoice,
'Product Perishability': product_perishability,
'Customer Inventory': cust_purchase_expected_expiry,
Expand All @@ -100,6 +93,8 @@ def main():
# Display selected page
if 'page' in st.session_state and st.session_state['page'] in pages:
pages[st.session_state['page']]()
else:
home()

# Copyright footer
st.markdown(
Expand Down
3 changes: 2 additions & 1 deletion Website/pages/OCR_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def convert_file_to_data(file_path, mime_type):

def ocr_invoice():
# st.set_page_config(page_title= "INVOICE-INFO EXTRACTOR")
st.write("<br>", unsafe_allow_html=True)

st.header("Invoice Details Extraction using OCR")
# input= st.text_input("Input Prompt: ", key= "input")
Expand Down Expand Up @@ -187,4 +188,4 @@ def ocr_invoice():
}, inplace=True)


st.dataframe(df_products)
st.dataframe(df_products, use_container_width=True)
7 changes: 4 additions & 3 deletions Website/pages/closest_supermarket.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def reset_user_input():
st.session_state.user_input = ''

def filter_dataframe(df, query):
return df[df['product_name'].str.contains(query, case=False, na=False)]
return df[df['Product Name'].str.contains(query, case=False, na=False)]

def button_clicked():
# Create a button and store its state
Expand All @@ -186,6 +186,7 @@ def button_clicked():
return None

def closest_supermarket():
st.write("<br>", unsafe_allow_html=True)

# import data using pandas if needed
# root_dir = os.path.abspath(os.path.join(os.getcwd()))
Expand Down Expand Up @@ -259,7 +260,7 @@ def closest_supermarket():

with col1:
st.write("Closest Supermarkets Data")
st.dataframe(df_closest_supermarkets) # Display the dataframe in the first column
st.dataframe(df_closest_supermarkets, use_container_width=True) # Display the dataframe in the first column

with col2:
st.write("Display Closest Supermarkets")
Expand All @@ -276,7 +277,7 @@ def closest_supermarket():
if selected_market == "Show All":
filtered_df = df_supermarkets.reset_index(drop=True)[['Store Name', 'Product Id', 'Product Name', 'Product Price', 'Quantity', 'Expiry Date']]
else:
filtered_df = df_supermarkets.query('store_name == @selected_market').reset_index(drop=True)[['Product Id', 'Product Name', 'Product Price', 'Quantity', 'Expiry Date']]
filtered_df = df_supermarkets.query("`Store Name` == @selected_market").reset_index(drop=True)[['Product Id', 'Product Name', 'Product Price', 'Quantity', 'Expiry Date']]
if user_query:
filtered_df = filter_dataframe(filtered_df, user_query)

Expand Down
6 changes: 4 additions & 2 deletions Website/pages/cust_purchase_expected_expiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ def cust_purchase_expected_expiry():
parquet_file_path = os.path.join(root_dir,'data', 'formatted_zone', 'purchases_nearing_expiry')

try:
st.write("## Estimation of Expected Expiry Date")
st.write("<br>", unsafe_allow_html=True)
st.header("Estimation of Expected Expiry Date")

col1, col2, col3, col4, col5, col6 = st.columns(6)
# Read the Parquet file into a DataFrame
df = load_data(parquet_file_path)
df = df[df['score']==100]

df = df[["customer_name", "product_name", "purchase_date", "expected_expiry_date"]]
df['customer_name'] = df['customer_name'].str.strip()
Expand Down Expand Up @@ -82,7 +84,7 @@ def cust_purchase_expected_expiry():
}, inplace=True)

st.write("<br>", unsafe_allow_html=True)
st.dataframe(df)
st.dataframe(df, use_container_width=True)

except FileNotFoundError as e:
st.error(f"File not found: {e}")
Expand Down
11 changes: 7 additions & 4 deletions Website/pages/dynamic_pricing_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# st.set_page_config(page_title="Dynamic Pricing", layout="wide")

# Title of the Streamlit app
st.title("Dynamic Pricing Model Results")
st.title("Dynamic Pricing")

# Specify the path to the GCS Parquet file
platform_customer_pricing_data_path = 'gs://formatted_zone/platform_customer_pricing_data_output'
Expand All @@ -52,6 +52,7 @@ def load_data_from_gcs(filepath):
return df

def dynamic_pricing_streamlit():
st.write("<br>", unsafe_allow_html=True)
# # Load the data from the parquet file
# @st.cache
# def load_data(parquet_path):
Expand All @@ -66,7 +67,7 @@ def dynamic_pricing_streamlit():
df['percentage_decrease'] = ((df['unit_price'] - df['dynamic_price']) / df['unit_price']) * 100

# Display the DataFrame
st.write("## Dynamic Pricing")
st.header("Dynamic Pricing")

# Enhanced Filtering
st.write("### Advanced Filters")
Expand Down Expand Up @@ -111,7 +112,7 @@ def dynamic_pricing_streamlit():
'selling_date': 'Selling Date'
}, inplace=True)

st.write(filtered_df.describe())
st.write(filtered_df.describe(),use_container_width=True)

# Key Metrics
st.write("### Key Metrics")
Expand Down Expand Up @@ -157,9 +158,11 @@ def convert_df_to_csv(df):
st.write("### Select Columns to Display")
all_columns = filtered_df.columns.tolist()
filtered_df = filtered_df[filtered_df['Score']==100]
all_columns = [col for col in all_columns if col not in ['product_in_avg_expiry_file','Score']]
selected_columns = st.multiselect("Select Columns", all_columns, default=all_columns)

st.dataframe(filtered_df[selected_columns])

st.dataframe(filtered_df[selected_columns], use_container_width=True)

# if __name__ == "__main__":
# st.write("Streamlit app is running. Adjust the sliders or filters to explore the data.")
Expand Down
3 changes: 2 additions & 1 deletion Website/pages/food_recommender.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ def initialize():


def food_recommender():
st.write("<br>", unsafe_allow_html=True)
processed_df = initialize()

st.title("Food Generator")
st.header("Recipe Recommendatioin")

user_ingredients = st.text_input("Enter ingredients, separated by commas", "rice, tomatoes")
ingredients_list = [ingredient.strip() for ingredient in user_ingredients.split(',')]
Expand Down
3 changes: 2 additions & 1 deletion Website/pages/product_perishability.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def load_data_from_gcs(filepath):

def product_perishability():
try:
st.write("## Perishability of Food Items")
st.write("<br>", unsafe_allow_html=True)
st.header("Perishability of Food Items")
col1, col2, col3, col4, col5 = st.columns(5)

estimated_avg_expiry_df = load_data_from_gcs(gcs_parquet_path)
Expand Down
3 changes: 2 additions & 1 deletion Website/pages/sentiment_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def display_reviews(df):

def sentiment_analysis():
# Streamlit App
st.title("Sentiment Analysis")
st.write("<br>", unsafe_allow_html=True)
st.header("Sentiment Analysis")

col1, col2, col3, col4, col5, col6, col7, col8, col9 = st.columns(9)

Expand Down
3 changes: 2 additions & 1 deletion Website/pages/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
spark = SparkSession.builder.getOrCreate()

def show_feature5():
st.header("TIME SERIES ANALYSIS")
st.write("<br>", unsafe_allow_html=True)
st.header("Time Series Analysis")

# Dropdown for selecting B2B or B2C
option = st.selectbox("Select Business Type", ("C2C", "C2C with expected price", "C2C with dynamic pricing", "B2C"))
Expand Down

0 comments on commit 6ca2a06

Please sign in to comment.