""" UI Components for Traffic Accident Reconstruction System ======================================================== Reusable Streamlit components for the application. """ import streamlit as st from config import CASE_STUDY_LOCATION, ALTERNATIVE_LOCATIONS def render_sidebar(): """Render the application sidebar.""" with st.sidebar: # MindSpore Logo at the top try: st.image("assets/mindspore_logo.png", width=120) except: st.markdown("### πŸ€– MindSpore") st.markdown("---") st.header("πŸš— Accident Analyzer") st.markdown(""" This system helps traffic authorities understand accidents through: - **AI-powered** scenario generation - **Real map** visualization - **2D simulation** of accidents - **Probability analysis** of scenarios """) st.markdown("---") st.subheader("πŸ“ Case Study Location") st.info(f""" **{CASE_STUDY_LOCATION['name']}** πŸ“ {CASE_STUDY_LOCATION['city']}, {CASE_STUDY_LOCATION['country']} πŸ—ΊοΈ Lat: {CASE_STUDY_LOCATION['latitude']:.4f} πŸ—ΊοΈ Lng: {CASE_STUDY_LOCATION['longitude']:.4f} """) st.markdown("---") st.subheader("πŸ“š Help") with st.expander("How to use"): st.markdown(""" 1. **Select Location**: View the roundabout location 2. **Vehicle 1**: Enter first vehicle details and draw its path 3. **Vehicle 2**: Enter second vehicle details and draw its path 4. **Analyze**: Let AI generate possible scenarios 5. **Results**: View scenarios with probability scores """) with st.expander("About MindSpore"): st.markdown(""" This system uses **Huawei MindSpore** for AI-powered scenario generation. MindSpore is an open-source deep learning framework optimized for Ascend processors. """) st.markdown("---") st.caption("Huawei AI Innovation Challenge 2026") def render_header(): """Render the application header.""" st.markdown("""

πŸš— Traffic Accident Reconstruction System

AI-Powered Analysis using Huawei MindSpore

""", unsafe_allow_html=True) def render_footer(): """Render the application footer.""" st.markdown("---") col1, col2, col3 = st.columns([2, 1, 2]) with col1: st.markdown("πŸ† **Huawei AI Innovation Challenge 2026**") with col2: # MindSpore logo in the center of footer try: st.image("assets/mindspore_logo.png", width=80) except: st.markdown("**[M]**") with col3: st.markdown("πŸ€– **Powered by MindSpore AI Framework**") def render_info_card(title: str, content: str, color: str = "#2d5a87"): """Render an information card.""" st.markdown(f"""

{title}

{content}

""", unsafe_allow_html=True) def render_metric_card(label: str, value: str, delta: str = None, color: str = "#2d5a87"): """Render a metric card.""" delta_html = "" if delta: delta_color = "#28a745" if "+" in delta or "High" in delta else "#dc3545" delta_html = f'{delta}' st.markdown(f"""

{label}

{value}

{delta_html}
""", unsafe_allow_html=True) def render_progress_bar(value: float, label: str = "", color: str = "#2d5a87"): """Render a custom progress bar.""" percentage = min(max(value * 100, 0), 100) st.markdown(f"""
{label} {percentage:.1f}%
""", unsafe_allow_html=True)