File size: 1,877 Bytes
454abe8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# app.py

import gradio as gr

# Sample material rates (PKR per unit area) by location
material_rates = {
    "Lahore": {
        "base_rate": 2500,
        "foundation": {"Shallow": 500, "Deep": 1000},
        "basement": 2000,
        "door": 15000,
        "window": 8000
    },
    "Karachi": {
        "base_rate": 2600,
        "foundation": {"Shallow": 600, "Deep": 1100},
        "basement": 2200,
        "door": 16000,
        "window": 8500
    },
    "Islamabad": {
        "base_rate": 2700,
        "foundation": {"Shallow": 550, "Deep": 1200},
        "basement": 2100,
        "door": 15500,
        "window": 9000
    }
}

def estimate_cost(area, stories, basement, foundation_type, doors, windows, location):
    rates = material_rates.get(location)
    if not rates:
        return "Location not supported."

    base = area * stories * rates["base_rate"]
    foundation = area * rates["foundation"][foundation_type]
    basement_cost = area * rates["basement"] if basement == "Yes" else 0
    doors_cost = doors * rates["door"]
    windows_cost = windows * rates["window"]

    total_cost = base + foundation + basement_cost + doors_cost + windows_cost
    return f"Estimated Cost: PKR {total_cost:,.0f}"

iface = gr.Interface(
    fn=estimate_cost,
    inputs=[
        gr.Number(label="Covered Area (sqft)"),
        gr.Number(label="Number of Stories"),
        gr.Radio(["Yes", "No"], label="Basement"),
        gr.Dropdown(["Shallow", "Deep"], label="Foundation Type"),
        gr.Number(label="Number of Doors"),
        gr.Number(label="Number of Windows"),
        gr.Dropdown(["Lahore", "Karachi", "Islamabad"], label="Building Location")
    ],
    outputs=gr.Textbox(label="Estimated Cost"),
    title="Building Cost Estimator - PKR",
    description="Estimate civil work cost of buildings based on area, location, and design."
)

iface.launch()