| import streamlit as st |
| import pandas as pd |
| import numpy as np |
| from PIL import Image |
| import io |
| import fitz |
|
|
| def process_drawing(uploaded_file): |
| try: |
| if uploaded_file.type == "application/pdf": |
| doc = fitz.open(stream=uploaded_file.read(), filetype="pdf") |
| page = doc[0] |
| pix = page.get_pixmap() |
| image = Image.frombytes("RGB", [pix.width, pix.height], pix.samples) |
| else: |
| image = Image.open(uploaded_file) |
| |
| st.image(image, caption="Uploaded Drawing", use_container_width=True) |
| return { |
| "build_area": 400, |
| "floors": {"Ground Floor": 154.1, "First Floor": 161.0, "Penthouse": 77.8}, |
| "excavation_volume": 100, |
| "blocks_required": 5000, |
| "plaster_work": 600, |
| "doors_windows": {"Doors": 10, "Windows": 20}, |
| "pcc_required": 50, |
| "rcc_required": 80, |
| "steel_required": 500, |
| "gypsum_boards": 200, |
| "areas": {"Living Room": 40, "Kitchen": 30, "Bedroom": 25} |
| } |
| except Exception as e: |
| st.error(f"Error processing file: {e}") |
| return None |
|
|
| st.title("Building Construction Estimator") |
| st.sidebar.header("Upload Drawing") |
|
|
| uploaded_file = st.sidebar.file_uploader("Upload your architectural drawing (PDF, PNG, JPG)", type=["pdf", "png", "jpg"]) |
|
|
| if uploaded_file: |
| data = process_drawing(uploaded_file) |
| if data: |
| st.subheader("Estimated Construction Details") |
| st.write(f"**Total Build Area:** {data['build_area']} sqm") |
| st.write("**Floors and Areas:**") |
| st.write(pd.DataFrame.from_dict(data["floors"], orient='index', columns=["Area (sqm)"])) |
| st.write(f"**Excavation Volume:** {data['excavation_volume']} cubic meters") |
| st.write(f"**Blocks Required:** {data['blocks_required']}") |
| st.write(f"**Plaster Work Required:** {data['plaster_work']} sqm") |
| st.write(f"**Doors and Windows Count:** {data['doors_windows']}") |
| st.write(f"**PCC Required:** {data['pcc_required']} cubic meters") |
| st.write(f"**RCC Required:** {data['rcc_required']} cubic meters") |
| st.write(f"**Steel Required:** {data['steel_required']} kg") |
| st.write(f"**Gypsum Boards Required:** {data['gypsum_boards']}") |
| |
| st.subheader("Find Area by Room Name") |
| room_name = st.text_input("Enter the room name:") |
| if room_name: |
| area = data["areas"].get(room_name, "Not found") |
| st.write(f"**Area of {room_name}:** {area} sqm") |
|
|