Update app.py
Browse files
app.py
CHANGED
|
@@ -6,11 +6,11 @@ import numpy as np # For numerical calculations
|
|
| 6 |
# App Configuration
|
| 7 |
st.set_page_config(page_title="Construction Site AR/VR Viewer", layout="wide")
|
| 8 |
|
| 9 |
-
# Sidebar - Navigation and
|
| 10 |
st.sidebar.title("Navigation")
|
| 11 |
-
view_option = st.sidebar.radio("Choose View:", ["Home", "
|
| 12 |
-
st.sidebar.title("
|
| 13 |
-
|
| 14 |
|
| 15 |
# App UI
|
| 16 |
st.title("Construction Site Visualization with AR/VR")
|
|
@@ -24,37 +24,62 @@ def load_sample_model():
|
|
| 24 |
mesh.compute_vertex_normals()
|
| 25 |
return mesh
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
if view_option == "Home":
|
| 28 |
st.image("https://via.placeholder.com/800x400.png?text=Construction+Site+Visualization", caption="Welcome Screen", use_column_width=True)
|
| 29 |
st.markdown(
|
| 30 |
-
"### Key Features:\n-
|
| 31 |
)
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
elif view_option == "3D Visualization":
|
| 34 |
st.subheader("3D Visualization of Construction Site")
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
st.text_input("Enter Issue Description:", placeholder="E.g., Incorrect pipe alignment in section B2")
|
| 45 |
-
uploaded_file = st.file_uploader("Upload Screenshot or 3D Model:", type=["png", "jpg", "3d"])
|
| 46 |
-
if st.button("Submit Annotation"):
|
| 47 |
-
st.success("Annotation submitted successfully!")
|
| 48 |
|
| 49 |
elif view_option == "Progress Updates":
|
| 50 |
st.subheader("Construction Progress Updates")
|
| 51 |
-
|
| 52 |
-
"
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
# Footer
|
| 60 |
st.markdown("---")
|
|
|
|
| 6 |
# App Configuration
|
| 7 |
st.set_page_config(page_title="Construction Site AR/VR Viewer", layout="wide")
|
| 8 |
|
| 9 |
+
# Sidebar - Navigation and Upload Section
|
| 10 |
st.sidebar.title("Navigation")
|
| 11 |
+
view_option = st.sidebar.radio("Choose View:", ["Home", "Upload Data", "3D Visualization", "Progress Updates"])
|
| 12 |
+
st.sidebar.title("Upload Data")
|
| 13 |
+
data_upload = st.sidebar.file_uploader("Upload Construction Site Data:", type=["csv", "json", "3d", "txt"])
|
| 14 |
|
| 15 |
# App UI
|
| 16 |
st.title("Construction Site Visualization with AR/VR")
|
|
|
|
| 24 |
mesh.compute_vertex_normals()
|
| 25 |
return mesh
|
| 26 |
|
| 27 |
+
# Process Uploaded Data
|
| 28 |
+
def process_uploaded_data(uploaded_file):
|
| 29 |
+
try:
|
| 30 |
+
if uploaded_file.name.endswith(".csv"):
|
| 31 |
+
data = pd.read_csv(uploaded_file)
|
| 32 |
+
st.write("Uploaded CSV Data:")
|
| 33 |
+
st.dataframe(data)
|
| 34 |
+
elif uploaded_file.name.endswith(".json"):
|
| 35 |
+
data = pd.read_json(uploaded_file)
|
| 36 |
+
st.write("Uploaded JSON Data:")
|
| 37 |
+
st.json(data)
|
| 38 |
+
elif uploaded_file.name.endswith(".3d") or uploaded_file.name.endswith(".obj"):
|
| 39 |
+
st.write("3D Model Uploaded. Displaying in Visualization Section.")
|
| 40 |
+
return uploaded_file
|
| 41 |
+
else:
|
| 42 |
+
st.error("Unsupported file format. Please upload CSV, JSON, or 3D model files.")
|
| 43 |
+
except Exception as e:
|
| 44 |
+
st.error(f"Error processing file: {e}")
|
| 45 |
+
|
| 46 |
if view_option == "Home":
|
| 47 |
st.image("https://via.placeholder.com/800x400.png?text=Construction+Site+Visualization", caption="Welcome Screen", use_column_width=True)
|
| 48 |
st.markdown(
|
| 49 |
+
"### Key Features:\n- Upload site data for AR/VR visualization.\n- Interactive walkthroughs.\n- Monitor progress updates and site analytics."
|
| 50 |
)
|
| 51 |
|
| 52 |
+
elif view_option == "Upload Data":
|
| 53 |
+
st.subheader("Upload Site Data")
|
| 54 |
+
if data_upload:
|
| 55 |
+
uploaded_model = process_uploaded_data(data_upload)
|
| 56 |
+
|
| 57 |
elif view_option == "3D Visualization":
|
| 58 |
st.subheader("3D Visualization of Construction Site")
|
| 59 |
+
if data_upload and uploaded_model:
|
| 60 |
+
try:
|
| 61 |
+
st.write("Displaying Uploaded 3D Model")
|
| 62 |
+
model = load_sample_model() # Replace with logic to load the uploaded model
|
| 63 |
+
o3d.visualization.draw_geometries([model])
|
| 64 |
+
except Exception as e:
|
| 65 |
+
st.error(f"Failed to load 3D model: {e}")
|
| 66 |
+
else:
|
| 67 |
+
st.info("Please upload a 3D model file in the Upload Data section.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
elif view_option == "Progress Updates":
|
| 70 |
st.subheader("Construction Progress Updates")
|
| 71 |
+
if data_upload:
|
| 72 |
+
st.write("Analyzing Progress from Uploaded Data...")
|
| 73 |
+
# Placeholder for progress analysis logic
|
| 74 |
+
progress_data = {
|
| 75 |
+
"Area": ["Mechanical", "Electrical", "Plumbing"],
|
| 76 |
+
"Progress (%)": [75, 60, 90]
|
| 77 |
+
}
|
| 78 |
+
progress_df = pd.DataFrame(progress_data)
|
| 79 |
+
st.table(progress_df)
|
| 80 |
+
st.bar_chart(progress_df.set_index("Area"))
|
| 81 |
+
else:
|
| 82 |
+
st.info("Please upload site data to view progress updates.")
|
| 83 |
|
| 84 |
# Footer
|
| 85 |
st.markdown("---")
|