Nionio commited on
Commit
77fc334
·
verified ·
1 Parent(s): 6f75d48

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -22
README.md CHANGED
@@ -1,22 +1,69 @@
1
- ---
2
- license: cc-by-4.0
3
- configs:
4
- - config_name: default
5
- data_files:
6
- - split: all_samples
7
- path: data/all_samples-*
8
- dataset_info:
9
- features:
10
- - name: Base_2_2/Zone/CellData/diffusion_coefficient
11
- list: float32
12
- - name: Base_2_2/Zone/CellData/flow
13
- list: float32
14
- - name: Global/forcing_magnitude
15
- list: float32
16
- splits:
17
- - name: all_samples
18
- num_bytes: 6554400000
19
- num_examples: 50000
20
- download_size: 3321884222
21
- dataset_size: 6554400000
22
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ configs:
4
+ - config_name: default
5
+ data_files:
6
+ - split: all_samples
7
+ path: data/all_samples-*
8
+ dataset_info:
9
+ features:
10
+ - name: Base_2_2/Zone/CellData/diffusion_coefficient
11
+ list: float32
12
+ - name: Base_2_2/Zone/CellData/flow
13
+ list: float32
14
+ - name: Global/forcing_magnitude
15
+ list: float32
16
+ splits:
17
+ - name: all_samples
18
+ num_bytes: 6554400000
19
+ num_examples: 50000
20
+ download_size: 3321884222
21
+ dataset_size: 6554400000
22
+ ---
23
+
24
+ Example of usage:
25
+
26
+ ```python
27
+ import torch
28
+ from plaid.bridges import huggingface_bridge as hfb
29
+ from torch.utils.data import DataLoader
30
+
31
+
32
+ def reshape_all(batch: dict[str, torch.Tensor]) -> dict[str, torch.Tensor]:
33
+ """Helper function that reshapes the flattened fields into images of sizes (128, 128)."""
34
+ batch["diffusion_coefficient"] = batch["diffusion_coefficient"].reshape(
35
+ -1, 128, 128
36
+ )
37
+
38
+ batch["flow"] = batch["flow"].reshape(-1, 128, 128)
39
+
40
+ return batch
41
+
42
+
43
+ # Load the dataset from the hub
44
+ ds = hfb.load_dataset_from_hub(
45
+ repo_id="Nionio/PDEBench_2D_DarcyFlow", split="all_samples"
46
+ )
47
+
48
+ # Rename the features
49
+ ds = ds.rename_columns(
50
+ {
51
+ "Base_2_2/Zone/CellData/diffusion_coefficient": "diffusion_coefficient",
52
+ "Base_2_2/Zone/CellData/flow": "flow",
53
+ "Global/forcing_magnitude": "forcing",
54
+ }
55
+ )
56
+
57
+ # Convert to torch
58
+ ds = ds.with_format("torch")
59
+
60
+ # Reshape fields
61
+ ds = ds.map(reshape_all, batched=True)
62
+
63
+ # Example of usage with a DataLoader
64
+ dl = DataLoader(ds, batch_size=32, shuffle=True)
65
+ for batch in dl:
66
+ for k, v in batch.items():
67
+ print(k, v.shape)
68
+ break
69
+ ```