Update README.md
Browse files
README.md
CHANGED
|
@@ -87,7 +87,9 @@ configs:
|
|
| 87 |
path: data/train-*
|
| 88 |
---
|
| 89 |
|
| 90 |
-
#
|
|
|
|
|
|
|
| 91 |
|
| 92 |
```py
|
| 93 |
import pickle
|
|
@@ -152,9 +154,42 @@ ds = Dataset.from_generator(gen)
|
|
| 152 |
ds = ds.with_format("numpy")
|
| 153 |
|
| 154 |
ds.push_to_hub("MLDS-NUS/polymer-dynamics_experimental-data")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
```
|
| 156 |
|
| 157 |
-
|
| 158 |
|
| 159 |
Directly loading by [datasets](https://huggingface.co/docs/datasets/installation) is supported now!
|
| 160 |
|
|
@@ -163,11 +198,12 @@ from datasets import load_dataset
|
|
| 163 |
import numpy as np
|
| 164 |
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
-
hf_dataset_30V = hf_dataset.filter(lambda x: x["config"] == "30V_Jan24")
|
| 170 |
-
hf_dataset_60V = hf_dataset.filter(lambda x: x["config"] == "60V_Dec24")
|
| 171 |
|
| 172 |
for sample in hf_dataset_30V:
|
| 173 |
for k, v in sample.items():
|
|
@@ -188,3 +224,41 @@ left_right: <class 'numpy.ndarray'>, shape=(160, 2), dtype=int64
|
|
| 188 |
barycenter: <class 'numpy.ndarray'>, shape=(160, 2), dtype=float32
|
| 189 |
```
|
| 190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
path: data/train-*
|
| 88 |
---
|
| 89 |
|
| 90 |
+
# Descriptions
|
| 91 |
+
|
| 92 |
+
## Converting script
|
| 93 |
|
| 94 |
```py
|
| 95 |
import pickle
|
|
|
|
| 154 |
ds = ds.with_format("numpy")
|
| 155 |
|
| 156 |
ds.push_to_hub("MLDS-NUS/polymer-dynamics_experimental-data")
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
# upload by configs
|
| 160 |
+
def gen(folder: str):
|
| 161 |
+
|
| 162 |
+
with open(DATA_DIR / f"{folder}.pkl", "rb") as f:
|
| 163 |
+
data = pickle.load(f)
|
| 164 |
+
|
| 165 |
+
for k, v in data.items():
|
| 166 |
+
frame = np.clip(v, 0, 255).astype(np.uint8)
|
| 167 |
+
left_rights = calc_left_right(255 - frame)
|
| 168 |
+
barycenters = calc_barycenter(255 - frame)
|
| 169 |
+
|
| 170 |
+
yield {
|
| 171 |
+
"config": folder,
|
| 172 |
+
"traj_id": k,
|
| 173 |
+
"shape": list(frame.shape),
|
| 174 |
+
"data": frame,
|
| 175 |
+
"left_right": left_rights,
|
| 176 |
+
"barycenter": barycenters,
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
for config_name in ["30V_Jan24", "60V_Dec24"]:
|
| 181 |
+
ds = Dataset.from_generator(lambda cn=config_name: gen(cn))
|
| 182 |
+
ds = ds.with_format("numpy")
|
| 183 |
+
|
| 184 |
+
ds.push_to_hub(
|
| 185 |
+
"MLDS-NUS/polymer-dynamics_experimental-data",
|
| 186 |
+
config_name=config_name,
|
| 187 |
+
data_dir=f"{config_name}",
|
| 188 |
+
)
|
| 189 |
+
|
| 190 |
```
|
| 191 |
|
| 192 |
+
## How to use
|
| 193 |
|
| 194 |
Directly loading by [datasets](https://huggingface.co/docs/datasets/installation) is supported now!
|
| 195 |
|
|
|
|
| 198 |
import numpy as np
|
| 199 |
|
| 200 |
|
| 201 |
+
hf_dataset_30V = load_dataset("MLDS-NUS/polymer-dynamics_experimental-data", config_name="30V_Jan24")
|
| 202 |
+
hf_dataset_60V = load_dataset("MLDS-NUS/polymer-dynamics_experimental-data", config_name="60V_Jan24")
|
| 203 |
+
|
| 204 |
+
hf_dataset_30V = hf_dataset_30V.with_format("numpy")["train"]
|
| 205 |
+
hf_dataset_60V = hf_dataset_60V.with_format("numpy")["train"]
|
| 206 |
|
|
|
|
|
|
|
| 207 |
|
| 208 |
for sample in hf_dataset_30V:
|
| 209 |
for k, v in sample.items():
|
|
|
|
| 224 |
barycenter: <class 'numpy.ndarray'>, shape=(160, 2), dtype=float32
|
| 225 |
```
|
| 226 |
|
| 227 |
+
## How to contribute
|
| 228 |
+
|
| 229 |
+
```py
|
| 230 |
+
import numpy as np
|
| 231 |
+
from datasets import Dataset
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
def gen(config_name: str):
|
| 235 |
+
|
| 236 |
+
for data in get_database(config_name):
|
| 237 |
+
|
| 238 |
+
frame = ...
|
| 239 |
+
traj_id = ...
|
| 240 |
+
shape = ...
|
| 241 |
+
left_rights = ...
|
| 242 |
+
barycenters = ...
|
| 243 |
+
|
| 244 |
+
yield {
|
| 245 |
+
"config": config_name,
|
| 246 |
+
"traj_id": traj_id,
|
| 247 |
+
"shape": shape,
|
| 248 |
+
"data": data, # a np.ndarray object of shape `shape`
|
| 249 |
+
"left_right": left_rights,
|
| 250 |
+
"barycenter": barycenters,
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
config_name = ...
|
| 255 |
+
ds = Dataset.from_generator(lambda cn=config_name: gen(cn))
|
| 256 |
+
ds = ds.with_format("numpy")
|
| 257 |
+
|
| 258 |
+
ds.push_to_hub(
|
| 259 |
+
"MLDS-NUS/polymer-dynamics_experimental-data",
|
| 260 |
+
config_name=config_name,
|
| 261 |
+
data_dir=f"{config_name}",
|
| 262 |
+
)
|
| 263 |
+
|
| 264 |
+
```
|