File size: 2,123 Bytes
2b416b4
 
 
 
 
 
 
 
 
 
aa23408
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: Upfront_Embodied_Carbon_Calculator
emoji: 📚
colorFrom: purple
colorTo: gray
sdk: gradio
sdk_version: 5.47.2
app_file: app.py
pinned: false
---
## A1–A5 Upfront Embodied Carbon Calculator (Gradio)

A single-page Gradio app to compute A1–A5 upfront embodied carbon for building materials and processes. Enter rows of data (materials, transport, site energy/waste), get per-row results, per-module summary, total tCO2e, and optional reduction suggestions powered by a small LLM via Hugging Face Inference API.

### Features
- Deterministic A1–A5 backend (EN 15978 scope; RICS/IStructE/GHG Protocol units)
- Units and aliases:
  - A1–A3/A5 materials/waste: `kg|t` × `kgCO2e/kg` or `tCO2e/t`
  - A4 transport: `ton_km` × `kgCO2e/ton_km` (aliases: `t-km`, `t·km`, `ton-km`)
  - A5 site energy: `kWh` × `kgCO2e/kWh`
- Output: per-row `kgCO2e|tCO2e`, per-module summary, `Total`
- Optional suggestions via Hugging Face Inference API (falls back to deterministic tips if no token)

### Run locally
```
pip install -r requirements.txt
python app.py
```
Open the local URL printed by Gradio.

### Deploy to Hugging Face Spaces
- Create a new Space (Gradio Python)
- Upload these files:
  - `app.py`
  - `requirements.txt`
  - `README.md` (optional)
- In Space Settings → Secrets, set one of the following if you want LLM suggestions:
  - `HUGGINGFACEHUB_API_TOKEN` (recommended), or
  - `HF_API_TOKEN`

If no token is set, the app still runs and shows rule-based fallback suggestions.

### Data columns (required)
`module,name,quantity,unit,ef,ef_unit,notes`

Examples:
- Concrete (A1): `10000 kg × 0.12 kgCO2e/kg`
- Rebar (A1): `2000 kg → 2 t × 1.9 tCO2e/t`
- CLT (A3): `5 t × 0.35 tCO2e/t`
- Truck transport (A4): `800 ton_km × 0.1 kgCO2e/ton_km`
- Construction waste (A5): `2 t × 0.25 tCO2e/t`

### Notes
- Backend validates missing columns, unsupported modules, and unit mismatches with clear errors
- Transport aliases are normalized to `ton_km`
- Keep provenance in `notes` (EPD/database/assumptions) for auditability

### License
MIT (user content and EPD/IP remain their respective owners)