# 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()