Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,11 +23,11 @@ st.set_page_config(page_title="GreenLens AI", layout="wide")
|
|
23 |
# Call the background function to load the background silently
|
24 |
add_background()
|
25 |
|
26 |
-
# Title and subtitle
|
27 |
-
st.markdown("<h1 style='text-align: center; color:
|
28 |
st.markdown(
|
29 |
"""
|
30 |
-
<p style='text-align: center; color:
|
31 |
A Comprehensive Tool for Assessing Water, Energy, and Carbon Footprints of Textile Products 🌍
|
32 |
</p>
|
33 |
""",
|
@@ -55,7 +55,6 @@ def process_dataset(url):
|
|
55 |
st.error(f"Error loading dataset: {e}")
|
56 |
return None, None, None
|
57 |
|
58 |
-
|
59 |
# Calculate footprints
|
60 |
def calculate_footprints(weight, composition, lifecycle_inputs):
|
61 |
water_fp, energy_fp, carbon_fp = 0, 0, 0
|
@@ -83,7 +82,6 @@ def calculate_footprints(weight, composition, lifecycle_inputs):
|
|
83 |
water_fp /= 1000 # Convert water from liters to kiloliters
|
84 |
return water_fp, energy_fp, carbon_fp
|
85 |
|
86 |
-
|
87 |
# Sidebar inputs
|
88 |
def get_inputs(prefix):
|
89 |
weight = st.sidebar.number_input(f"{prefix} Product Weight (kg)", min_value=0.0, value=0.0, step=0.01, key=f"{prefix}_weight")
|
@@ -114,6 +112,14 @@ def get_inputs(prefix):
|
|
114 |
}
|
115 |
return weight, composition, lifecycle_inputs
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
# Main application logic
|
119 |
fiber_impact_data, transport_impact_data, washing_impact_data = process_dataset(DATASET_URL)
|
@@ -151,7 +157,7 @@ if fiber_impact_data and transport_impact_data and washing_impact_data:
|
|
151 |
color="Assessment",
|
152 |
title="Comparison of Assessments"
|
153 |
)
|
154 |
-
st.plotly_chart(fig)
|
155 |
|
156 |
else:
|
157 |
# Input for a single assessment
|
@@ -170,6 +176,6 @@ if fiber_impact_data and transport_impact_data and washing_impact_data:
|
|
170 |
"Value": [water, energy, carbon]
|
171 |
})
|
172 |
fig = px.bar(result_data, x="Footprint Type", y="Value", title="Single Assessment Footprint Breakdown")
|
173 |
-
st.plotly_chart(fig)
|
174 |
else:
|
175 |
st.error("Failed to load dataset.")
|
|
|
23 |
# Call the background function to load the background silently
|
24 |
add_background()
|
25 |
|
26 |
+
# Title and subtitle with updated color
|
27 |
+
st.markdown("<h1 style='text-align: center; color: white;'>GreenLens AI</h1>", unsafe_allow_html=True)
|
28 |
st.markdown(
|
29 |
"""
|
30 |
+
<p style='text-align: center; color: white; font-size: 18px;'>
|
31 |
A Comprehensive Tool for Assessing Water, Energy, and Carbon Footprints of Textile Products 🌍
|
32 |
</p>
|
33 |
""",
|
|
|
55 |
st.error(f"Error loading dataset: {e}")
|
56 |
return None, None, None
|
57 |
|
|
|
58 |
# Calculate footprints
|
59 |
def calculate_footprints(weight, composition, lifecycle_inputs):
|
60 |
water_fp, energy_fp, carbon_fp = 0, 0, 0
|
|
|
82 |
water_fp /= 1000 # Convert water from liters to kiloliters
|
83 |
return water_fp, energy_fp, carbon_fp
|
84 |
|
|
|
85 |
# Sidebar inputs
|
86 |
def get_inputs(prefix):
|
87 |
weight = st.sidebar.number_input(f"{prefix} Product Weight (kg)", min_value=0.0, value=0.0, step=0.01, key=f"{prefix}_weight")
|
|
|
112 |
}
|
113 |
return weight, composition, lifecycle_inputs
|
114 |
|
115 |
+
# Adjust graph transparency
|
116 |
+
def style_figure(fig):
|
117 |
+
fig.update_layout(
|
118 |
+
plot_bgcolor="rgba(0,0,0,0.3)", # 30% transparent black
|
119 |
+
paper_bgcolor="rgba(0,0,0,0.3)", # 30% transparent black
|
120 |
+
font=dict(color="white") # Set font color to white for better visibility
|
121 |
+
)
|
122 |
+
return fig
|
123 |
|
124 |
# Main application logic
|
125 |
fiber_impact_data, transport_impact_data, washing_impact_data = process_dataset(DATASET_URL)
|
|
|
157 |
color="Assessment",
|
158 |
title="Comparison of Assessments"
|
159 |
)
|
160 |
+
st.plotly_chart(style_figure(fig))
|
161 |
|
162 |
else:
|
163 |
# Input for a single assessment
|
|
|
176 |
"Value": [water, energy, carbon]
|
177 |
})
|
178 |
fig = px.bar(result_data, x="Footprint Type", y="Value", title="Single Assessment Footprint Breakdown")
|
179 |
+
st.plotly_chart(style_figure(fig))
|
180 |
else:
|
181 |
st.error("Failed to load dataset.")
|