Update streamlit_app.py
Browse files- streamlit_app.py +145 -146
streamlit_app.py
CHANGED
|
@@ -1,146 +1,145 @@
|
|
| 1 |
-
#streamlit run your_script.py
|
| 2 |
-
import streamlit as st
|
| 3 |
-
import os
|
| 4 |
-
import sys
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
'''
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
st.
|
| 100 |
-
st.
|
| 101 |
-
st.
|
| 102 |
-
st.
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
st.markdown("
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
<
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
st.
|
| 123 |
-
st.write("")
|
| 124 |
-
st.
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
st.write("")
|
| 128 |
-
st.write("")
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
st.
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
st.Page(Path(BASE_DIR) / "navigation" / "
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
| 1 |
+
#streamlit run your_script.py
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
st.set_page_config(
|
| 8 |
+
page_title="F1 Video Analysis Platform",
|
| 9 |
+
page_icon="🏎️",
|
| 10 |
+
initial_sidebar_state="expanded",
|
| 11 |
+
layout="wide"
|
| 12 |
+
)
|
| 13 |
+
from utils.helper import BASE_DIR,metrics_page
|
| 14 |
+
if "visited" not in st.session_state:
|
| 15 |
+
st.session_state["visited"] = True
|
| 16 |
+
try:
|
| 17 |
+
metrics_page.update_one({"page": "inicio"}, {"$inc": {"visits": 1}})
|
| 18 |
+
except:
|
| 19 |
+
st.warning("MongoDB client not connected.")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
hide_decoration_bar_style = '''
|
| 23 |
+
<style>
|
| 24 |
+
header {visibility: hidden;}
|
| 25 |
+
</style>
|
| 26 |
+
'''
|
| 27 |
+
logo_style = '''
|
| 28 |
+
<style>
|
| 29 |
+
/* Estilo para iconos de contacto - versión compacta */
|
| 30 |
+
.contact-icons {
|
| 31 |
+
display: flex;
|
| 32 |
+
justify-content: center;
|
| 33 |
+
gap: 8px;
|
| 34 |
+
margin-top: 10px;
|
| 35 |
+
flex-wrap: wrap;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.contact-icon {
|
| 39 |
+
display: flex;
|
| 40 |
+
align-items: center;
|
| 41 |
+
padding: 6px;
|
| 42 |
+
border-radius: 50%;
|
| 43 |
+
background-color: rgba(255, 255, 255, 0.1);
|
| 44 |
+
transition: all 0.3s ease;
|
| 45 |
+
text-decoration: none;
|
| 46 |
+
color: #ffffff;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.contact-icon:hover {
|
| 50 |
+
background-color: rgba(255, 255, 255, 0.2);
|
| 51 |
+
transform: translateY(-2px);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.contact-icon img {
|
| 55 |
+
width: 16px;
|
| 56 |
+
height: 16px;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/* Email button style */
|
| 60 |
+
.email-button {
|
| 61 |
+
display: flex;
|
| 62 |
+
align-items: center;
|
| 63 |
+
justify-content: center;
|
| 64 |
+
padding: 8px 15px;
|
| 65 |
+
border-radius: 20px;
|
| 66 |
+
background-color: rgba(255, 255, 255, 0.1);
|
| 67 |
+
transition: all 0.3s ease;
|
| 68 |
+
text-decoration: none;
|
| 69 |
+
color: #ffffff;
|
| 70 |
+
font-size: 13px;
|
| 71 |
+
margin-top: 12px;
|
| 72 |
+
width: 100%;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.email-button:hover {
|
| 76 |
+
background-color: rgba(255, 255, 255, 0.2);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.email-button img {
|
| 80 |
+
width: 16px;
|
| 81 |
+
height: 16px;
|
| 82 |
+
margin-right: 8px;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/* Estilo para el separador */
|
| 86 |
+
.sidebar-separator {
|
| 87 |
+
margin: 20px 0;
|
| 88 |
+
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
| 89 |
+
}
|
| 90 |
+
</style>
|
| 91 |
+
'''
|
| 92 |
+
#sst.markdown(hide_decoration_bar_style, unsafe_allow_html=True)logo_style
|
| 93 |
+
st.markdown(logo_style, unsafe_allow_html=True)
|
| 94 |
+
|
| 95 |
+
#st.markdown("<br>",unsafe_allow_html=True)
|
| 96 |
+
|
| 97 |
+
with st.sidebar:
|
| 98 |
+
st.markdown("<h3 style='text-align: center; color: #fff;'>Considerations</h3>", unsafe_allow_html=True)
|
| 99 |
+
st.caption("""**Ouput Data**:""")
|
| 100 |
+
st.markdown("<p style='text-align: left; color: gray; font-size: 12px;'>The model is trained with images from -180° to 180°, for the moment may not accurately predict angles beyond 180°. Poor or high-intensity lighting may affect data accuracy.</p>", unsafe_allow_html=True)
|
| 101 |
+
st.caption("""**Usage**:""")
|
| 102 |
+
st.markdown("<p style='text-align: left; color: gray; font-size: 12px;'>Free-tier server resources are limited, so the page may be slow or crash with large files. To run it locally, feel free to fork/clone the project or download the desktop app.</p>", unsafe_allow_html=True)
|
| 103 |
+
|
| 104 |
+
st.markdown("<p style='text-align: left; color: gray; font-size: 12px;'>Any feedback is welcome.</p>", unsafe_allow_html=True)
|
| 105 |
+
st.markdown("", unsafe_allow_html=True)
|
| 106 |
+
|
| 107 |
+
st.markdown("<h3 style='text-align: center; color: #fff;'>Contact</h3>", unsafe_allow_html=True)
|
| 108 |
+
# Nueva versión más compacta de los iconos
|
| 109 |
+
contact_html = """
|
| 110 |
+
<div class="contact-icons">
|
| 111 |
+
<a href='https://x.com/justsaed' target="_blank" class="contact-icon" title="X">
|
| 112 |
+
<img src="https://static.vecteezy.com/system/resources/previews/053/986/348/non_2x/x-twitter-icon-logo-symbol-free-png.png" alt="X">
|
| 113 |
+
</a>
|
| 114 |
+
<a href="https://github.com/danielsaed/F1-steering-angle-model" target="_blank" class="contact-icon" title="GitHub">
|
| 115 |
+
<img src="https://cdn-icons-png.flaticon.com/512/25/25231.png" alt="GitHub">
|
| 116 |
+
</a>
|
| 117 |
+
</div>
|
| 118 |
+
|
| 119 |
+
"""
|
| 120 |
+
|
| 121 |
+
st.markdown(contact_html, unsafe_allow_html=True)
|
| 122 |
+
st.write("")
|
| 123 |
+
st.write("")
|
| 124 |
+
st.markdown("<p style='text-align: center; color: gray; font-size: 10px;'>For research/educational purposes only</p>", unsafe_allow_html=True)
|
| 125 |
+
|
| 126 |
+
st.write("")
|
| 127 |
+
st.write("")
|
| 128 |
+
st.write("")
|
| 129 |
+
|
| 130 |
+
st.markdown("<h3 style='text-align: center; color: #fff;'>Get Desktop App</h3>", unsafe_allow_html=True)
|
| 131 |
+
col1,col2, col3 = st.columns([1,6,1])
|
| 132 |
+
with col2:
|
| 133 |
+
|
| 134 |
+
st.markdown("<p style='text-align: center; color: gray; font-size: 10px;'>Click Assets then download .exe</p>", unsafe_allow_html=True)
|
| 135 |
+
st.link_button("Download", "https://github.com/danielsaed/F1-steering-angle-model/releases",type="secondary",use_container_width=True)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
pages = st.navigation({
|
| 139 |
+
"Steering Angle Model": [
|
| 140 |
+
st.Page(Path(BASE_DIR) / "navigation" / "steering-angle.py", title="Use Model"),
|
| 141 |
+
st.Page(Path(BASE_DIR) / "navigation" / "soon.py", title="Historical Steering Data Base"),
|
| 142 |
+
],})
|
| 143 |
+
|
| 144 |
+
pages.run()
|
| 145 |
+
|
|
|