Talha1786 commited on
Commit
e1031bb
·
verified ·
1 Parent(s): adb1f3a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +77 -0
app.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def calculate_bricks(wall_length, wall_height, wall_thickness, brick_length, brick_height, brick_width, mortar_thickness):
4
+ # Adjusting brick size to include mortar thickness (convert inches to meters)
5
+ mortar_thickness_meters = mortar_thickness * 0.0254 # convert from inches to meters
6
+ effective_brick_length = (brick_length + mortar_thickness) * 0.0254 # convert from inches to meters
7
+ effective_brick_height = (brick_height + mortar_thickness) * 0.0254 # convert from inches to meters
8
+ effective_brick_width = (brick_width + mortar_thickness) * 0.0254 # convert from inches to meters
9
+
10
+ # Calculating wall and brick volumes
11
+ wall_volume = wall_length * wall_height * wall_thickness # wall volume in cubic feet
12
+ brick_volume = effective_brick_length * effective_brick_height * effective_brick_width # brick volume in cubic meters
13
+
14
+ # Total number of bricks required
15
+ total_bricks = wall_volume / brick_volume
16
+
17
+ return int(total_bricks)
18
+
19
+ def calculate_mortar_requirements(total_bricks):
20
+ # Approximate requirements based on standard mix ratios (1:6 for cement:sand)
21
+ # Cement per 1000 bricks = 3 bags (approx. 50 kg each)
22
+ # Sand per 1000 bricks = 0.6 m³
23
+ # Water per 1000 bricks = 0.3 m³
24
+
25
+ cement_bags = (total_bricks / 1000) * 3
26
+ sand_volume = (total_bricks / 1000) * 0.6
27
+ water_volume = (total_bricks / 1000) * 0.3
28
+
29
+ return round(cement_bags, 2), round(sand_volume, 2), round(water_volume, 2)
30
+
31
+ # Streamlit UI
32
+ st.set_page_config(page_title="Bricks Estimator", layout="wide")
33
+ st.title("Bricks Estimator")
34
+ st.markdown("""
35
+ Estimate the number of bricks and the mortar requirements for your construction project.
36
+ Enter the wall dimensions in feet and the brick size in inches.
37
+ """)
38
+
39
+ # Sidebar Inputs for Wall Dimensions
40
+ st.sidebar.header("Enter Wall Dimensions")
41
+ wall_length = st.sidebar.number_input("Wall Length (in feet)", min_value=0.1, step=0.1, value=10.0)
42
+ wall_height = st.sidebar.number_input("Wall Height (in feet)", min_value=0.1, step=0.1, value=8.0)
43
+ wall_thickness = st.sidebar.number_input("Wall Thickness (in feet)", min_value=0.05, step=0.01, value=0.5)
44
+
45
+ # Sidebar Inputs for Brick Dimensions
46
+ st.sidebar.header("Enter Brick Dimensions (in inches)")
47
+ brick_length = st.sidebar.number_input("Brick Length (in inches)", min_value=1, step=1, value=8)
48
+ brick_height = st.sidebar.number_input("Brick Height (in inches)", min_value=1, step=1, value=4)
49
+ brick_width = st.sidebar.number_input("Brick Width (in inches)", min_value=1, step=1, value=3)
50
+
51
+ # Sidebar Input for Mortar Thickness
52
+ st.sidebar.header("Enter Mortar Thickness (in inches)")
53
+ mortar_thickness = st.sidebar.number_input("Mortar Thickness", min_value=0, step=0.1, value=0.5)
54
+
55
+ # Main Area: Display Results after "Generate" button is clicked
56
+ col1, col2 = st.columns([3, 2])
57
+
58
+ with col1:
59
+ if st.button("Generate"):
60
+ total_bricks = calculate_bricks(wall_length, wall_height, wall_thickness, brick_length, brick_height, brick_width, mortar_thickness)
61
+ cement_bags, sand_volume, water_volume = calculate_mortar_requirements(total_bricks)
62
+
63
+ st.subheader("Results")
64
+ st.write(f"**Total Bricks Required:** {total_bricks}")
65
+ st.write(f"**Cement Required:** {cement_bags} bags (50 kg each)")
66
+ st.write(f"**Sand Required:** {sand_volume} m³")
67
+ st.write(f"**Water Required:** {water_volume} m³")
68
+
69
+ with col2:
70
+ st.image("https://via.placeholder.com/300x200.png?text=Brick+Estimator", caption="Your Construction Partner", use_column_width=True)
71
+
72
+ st.markdown("---")
73
+ st.markdown("""
74
+ <div style="text-align:center;">
75
+ <a href="https://huggingface.co/spaces/your_space_url" target="_blank">Deploy on Hugging Face</a>
76
+ </div>
77
+ """, unsafe_allow_html=True)