Spaces:
Sleeping
Sleeping
Upload streamlit_app (1).py
Browse files- streamlit_app (1).py +61 -0
streamlit_app (1).py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
from model import predict_kara_layout
|
| 6 |
+
|
| 7 |
+
st.set_page_config(page_title="KARA II Layout – Regression v1", layout="wide")
|
| 8 |
+
|
| 9 |
+
st.title("🧠 KARA II System Design – Regression Model v1")
|
| 10 |
+
|
| 11 |
+
st.markdown(
|
| 12 |
+
"""
|
| 13 |
+
This app uses a **tiny regression model** trained on synthetic KARA II layouts.
|
| 14 |
+
|
| 15 |
+
- Input **room dimensions** and **boxes per side**
|
| 16 |
+
- The model predicts **X, Y, Z, Ver, Hor, Rot** for each element of the L/R arrays
|
| 17 |
+
- Download results as CSV for use in EASE / Soundvision / spreadsheets
|
| 18 |
+
"""
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
with st.sidebar:
|
| 22 |
+
st.header("Room Parameters")
|
| 23 |
+
room_length = st.number_input("Room Length (ft)", min_value=40.0, max_value=300.0, value=100.0, step=1.0)
|
| 24 |
+
room_width = st.number_input("Room Width (ft)", min_value=30.0, max_value=200.0, value=80.0, step=1.0)
|
| 25 |
+
room_height = st.number_input("Room Height (ft)", min_value=15.0, max_value=80.0, value=40.0, step=1.0)
|
| 26 |
+
|
| 27 |
+
st.header("Array Parameters")
|
| 28 |
+
boxes_per_side = st.number_input("Boxes per Side", min_value=4, max_value=15, value=15, step=1)
|
| 29 |
+
system_id = st.number_input("System ID", min_value=1, max_value=9999, value=1, step=1)
|
| 30 |
+
|
| 31 |
+
generate = st.button("Generate Layout (ML Model)")
|
| 32 |
+
|
| 33 |
+
if generate:
|
| 34 |
+
rows = predict_kara_layout(
|
| 35 |
+
room_length=float(room_length),
|
| 36 |
+
room_width=float(room_width),
|
| 37 |
+
room_height=float(room_height),
|
| 38 |
+
boxes_per_side=int(boxes_per_side),
|
| 39 |
+
system_id=int(system_id),
|
| 40 |
+
)
|
| 41 |
+
df_layout = pd.DataFrame(rows)
|
| 42 |
+
|
| 43 |
+
st.subheader("Predicted Layout Table")
|
| 44 |
+
st.dataframe(df_layout, use_container_width=True)
|
| 45 |
+
|
| 46 |
+
csv_bytes = df_layout.to_csv(index=False).encode("utf-8")
|
| 47 |
+
st.download_button(
|
| 48 |
+
label="⬇️ Download CSV",
|
| 49 |
+
data=csv_bytes,
|
| 50 |
+
file_name=f"kara_layout_sys{system_id}.csv",
|
| 51 |
+
mime="text/csv",
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
st.subheader("Quick Preview (Top 10 Rows)")
|
| 55 |
+
st.write(
|
| 56 |
+
df_layout[["Label", "X", "Y", "Z", "Ver_deg"]]
|
| 57 |
+
.head(10)
|
| 58 |
+
.style.format({"X": "{:.2f}", "Y": "{:.2f}", "Z": "{:.2f}", "Ver_deg": "{:.1f}"})
|
| 59 |
+
)
|
| 60 |
+
else:
|
| 61 |
+
st.info("Set your room + array parameters in the sidebar, then click **Generate Layout (ML Model)**.")
|