Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,9 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
import plotly.express as px
|
4 |
|
5 |
-
# Add custom CSS for the background
|
6 |
def add_background():
|
7 |
-
background_url = "https://huggingface.co/spaces/ZainMalik0925/GreenLensAI_LCA/resolve/main/
|
8 |
css = f"""
|
9 |
<style>
|
10 |
.stApp {{
|
@@ -17,6 +17,7 @@ def add_background():
|
|
17 |
background-color: rgba(27, 27, 27, 0.7); /* 70% Opaque Black Background */
|
18 |
padding: 10px;
|
19 |
border-radius: 5px;
|
|
|
20 |
color: white;
|
21 |
}}
|
22 |
</style>
|
@@ -91,7 +92,7 @@ def calculate_footprints(weight, composition, lifecycle_inputs):
|
|
91 |
# Sidebar inputs
|
92 |
def get_inputs(prefix):
|
93 |
weight = st.sidebar.number_input(f"{prefix} Product Weight (kg)", min_value=0.0, value=0.0, step=0.01, key=f"{prefix}_weight")
|
94 |
-
st.sidebar.markdown(f"<h3 style='color:
|
95 |
cotton = st.sidebar.number_input("Conventional Cotton (%)", 0, 100, 0, step=1, key=f"{prefix}_cotton")
|
96 |
polyester = st.sidebar.number_input("Polyester (%)", 0, 100, 0, step=1, key=f"{prefix}_polyester")
|
97 |
nylon = st.sidebar.number_input("Nylon 6 (%)", 0, 100, 0, step=1, key=f"{prefix}_nylon")
|
@@ -158,6 +159,21 @@ if fiber_impact_data and transport_impact_data and washing_impact_data:
|
|
158 |
</div>
|
159 |
""", unsafe_allow_html=True)
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
else:
|
162 |
# Input for a single assessment
|
163 |
weight, composition, lifecycle = get_inputs("Single")
|
@@ -172,3 +188,13 @@ if fiber_impact_data and transport_impact_data and washing_impact_data:
|
|
172 |
<p>- **Carbon Footprint**: {carbon:.2f} kg CO2e</p>
|
173 |
</div>
|
174 |
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import pandas as pd
|
3 |
import plotly.express as px
|
4 |
|
5 |
+
# Add custom CSS for the app background and text styling
|
6 |
def add_background():
|
7 |
+
background_url = "https://huggingface.co/spaces/ZainMalik0925/GreenLensAI_LCA/resolve/main/BCK1.jpg"
|
8 |
css = f"""
|
9 |
<style>
|
10 |
.stApp {{
|
|
|
17 |
background-color: rgba(27, 27, 27, 0.7); /* 70% Opaque Black Background */
|
18 |
padding: 10px;
|
19 |
border-radius: 5px;
|
20 |
+
margin-bottom: 15px;
|
21 |
color: white;
|
22 |
}}
|
23 |
</style>
|
|
|
92 |
# Sidebar inputs
|
93 |
def get_inputs(prefix):
|
94 |
weight = st.sidebar.number_input(f"{prefix} Product Weight (kg)", min_value=0.0, value=0.0, step=0.01, key=f"{prefix}_weight")
|
95 |
+
st.sidebar.markdown(f"<h3 style='color: black;'>{prefix} Material Composition (%)</h3>", unsafe_allow_html=True)
|
96 |
cotton = st.sidebar.number_input("Conventional Cotton (%)", 0, 100, 0, step=1, key=f"{prefix}_cotton")
|
97 |
polyester = st.sidebar.number_input("Polyester (%)", 0, 100, 0, step=1, key=f"{prefix}_polyester")
|
98 |
nylon = st.sidebar.number_input("Nylon 6 (%)", 0, 100, 0, step=1, key=f"{prefix}_nylon")
|
|
|
159 |
</div>
|
160 |
""", unsafe_allow_html=True)
|
161 |
|
162 |
+
# Bar chart comparison
|
163 |
+
comparison_data = pd.DataFrame({
|
164 |
+
"Footprint Type": ["Water (kL)", "Energy (MJ)", "Carbon (kg CO2e)"],
|
165 |
+
"Assessment 1": [water1, energy1, carbon1],
|
166 |
+
"Assessment 2": [water2, energy2, carbon2],
|
167 |
+
})
|
168 |
+
fig = px.bar(
|
169 |
+
comparison_data.melt(id_vars="Footprint Type", var_name="Assessment", value_name="Value"),
|
170 |
+
x="Footprint Type",
|
171 |
+
y="Value",
|
172 |
+
color_discrete_sequence=["white"],
|
173 |
+
title="Comparison of Assessments"
|
174 |
+
)
|
175 |
+
st.plotly_chart(style_figure(fig))
|
176 |
+
|
177 |
else:
|
178 |
# Input for a single assessment
|
179 |
weight, composition, lifecycle = get_inputs("Single")
|
|
|
188 |
<p>- **Carbon Footprint**: {carbon:.2f} kg CO2e</p>
|
189 |
</div>
|
190 |
""", unsafe_allow_html=True)
|
191 |
+
|
192 |
+
# Bar chart for single assessment
|
193 |
+
result_data = pd.DataFrame({
|
194 |
+
"Footprint Type": ["Water (kL)", "Energy (MJ)", "Carbon (kg CO2e)"],
|
195 |
+
"Value": [water, energy, carbon]
|
196 |
+
})
|
197 |
+
fig = px.bar(result_data, x="Footprint Type", y="Value", title="Single Assessment Footprint Breakdown")
|
198 |
+
st.plotly_chart(style_figure(fig))
|
199 |
+
else:
|
200 |
+
st.error("Failed to load dataset.")
|