Spaces:
Sleeping
Sleeping
File size: 5,023 Bytes
bcad657 773d57a bcad657 b4b48c2 924eb3a 89ce392 bcad657 655c3fa bcad657 655c3fa bcad657 469032d bcad657 cd478f2 bcad657 f5d228a de8ce68 bcad657 773d57a bcad657 773d57a da1823a 773d57a 4201668 773d57a bcad657 6159b08 bcad657 de8ce68 bcad657 b4b48c2 bcad657 b4b48c2 bcad657 a8b82d2 773d57a bcad657 |
1 2 3 4 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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
import streamlit as st
import sys
import os
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import torch
import numpy as np
import threading
import hmac
from processing.surface_plots import surface_plot
from processing.preprocessing import plot_timeseries
from processing.prediction import NN_prediction
from processing.barsplots_rootcauses import check_classification
from processing.cloud_access import auto_download
from processing.processing_data import slice_data
from processing.processing_data import create_recurrence_plot
from processing.processing_data import classification
seafile_token = os.environ['SEAFILE_TOKEN']
def get_csv_files(data_folder):
csv_files = []
for file in os.listdir(data_folder):
if file.endswith(".csv"):
csv_file = os.path.join(data_folder, file)
csv_files.append(csv_file)
return csv_files
def check_password():
"""Returns `True` if the user had the correct password."""
def password_entered():
"""Checks whether a password entered by the user is correct."""
if hmac.compare_digest(st.session_state["password"], st.secrets["password"]):
st.session_state["password_correct"] = True
del st.session_state["password"] # Don't store the password.
else:
st.session_state["password_correct"] = False
# Return True if the password is validated.
if st.session_state.get("password_correct", False):
return True
# Show input for password.
st.text_input(
"Password", type="password", on_change=password_entered, key="password"
)
if "password_correct" in st.session_state:
st.error("😕 Password incorrect")
return False
if not check_password():
st.stop() # Do not continue if check_password is not True.
def main():
sprint_data_folder = "Messungen"
sprint_csv_files = get_csv_files(sprint_data_folder)
st.set_page_config(page_title="Assistenzsystem", page_icon=":eyeglasses:", layout="wide")
with open("assets/style.css") as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
st.write("")
col1, col2 = st.columns([1, 0.2])
with col1: st.image("assets/ProKI_Logo.png", width=200)
with col2: st.image("assets/qr-code.png", width=100)
#with col2: st.markdown("<h2 style='text-align: right; color: black; font-family:Arial;font-size:2.25rem;'>Assistenzsystem</h2>", unsafe_allow_html=True)
tab1, tab2 = st.tabs(["Auswertung", "Modellierung der Bauteilqualität"])
with tab1:
selected_file = st.selectbox("Oberflächenscan auswählen", sprint_csv_files, 0)
col1, col_blanc, col2= st.columns([0.45, 0.1, 0.40], gap="large")
with col1:
try:
fig = surface_plot(selected_file)
fig.update_layout(height=800, width=1100)
st.plotly_chart(fig, theme="streamlit", use_container_width=False)
except:
pass
with col_blanc:
st.write("")
with col2:
st.markdown("<h2 style='text-align: center; color: black; font-family:Arial;font-size:2rem;'>Auswertung</h2>", unsafe_allow_html=True)
try:
sliced_data = slice_data(selected_file)
recurrence_plot = create_recurrence_plot(sliced_data)
classification_result = classification(recurrence_plot)
fig_feed, fig_depth, fig_wear = check_classification(classification_result)
st.pyplot(fig_feed)
st.pyplot(fig_depth)
st.pyplot(fig_wear)
except:
pass
with tab2:
st.markdown("#")
col1, col2, col3 = st.columns([0.5, 0.1, 0.4], gap="large")
with col1:
feed = st.slider("Vorschub [mm/min]", 400, 1300, 1300)
plaindepth = st.slider("Schnitttiefe [mm]", 0.1, 0.5, 0.1)
wear = st.slider("Werkzeugverschleiß %", 0, 100, 0)
try:
fig = NN_prediction((feed-400)/900, (plaindepth-0.1)/0.4, wear/100)
st.pyplot(fig)
except:
st.write("Models not loaded yet")
with col2:
st.write("")
with col3:
st.write("")
st.image("assets/slice.png")
# auswahl = st.radio("Merkmal", ["Vorschub", "Schnitttiefe", "Werkzeugverschleiß"], horizontal=True, index=0)
# #width = 500
# if auswahl == "Vorschub":
# st.image("assets/max_Vorschub.PNG")
# elif auswahl == "Schnitttiefe":
# st.image("assets/max_Schnitttiefe.PNG")
# else:
# st.image("assets/max_Verschleiß.PNG")
if __name__ == "__main__":
main()
t1 = threading.Thread(target=auto_download, args=(seafile_token,))
t1.start()
|