windtunnel / windtunnel.py
rvalerio's picture
Upload folder using huggingface_hub
c2ac2e7 verified
raw
history blame
1.96 kB
import json
import os
import datasets
class WindtunnelDataset(datasets.GeneratorBasedBuilder):
"""Dataset for loading simulation data with JSON and mesh files"""
def _info(self):
return datasets.DatasetInfo(
features=datasets.Features(
{
"coeff": datasets.Value("binary"), # JSON file as a dictionary
"input": datasets.Value("binary"), # JSON file as a dictionary
"input_mesh": datasets.Value("binary"), # OBJ mesh file as binary
"openfoam_mesh": datasets.Value(
"binary"
), # OBJ mesh file as binary
"pressure_field_mesh": datasets.Value(
"binary"
), # VTK file as binary
"streamlines_mesh": datasets.Value("binary"), # PLY file as binary
}
),
homepage="https://inductiva.ai",
)
def _split_generators(self, dl_manager):
"""Define the splits for the dataset."""
train_dir = "train"
val_dir = "validation"
test_dir = "test"
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN, gen_kwargs={"path": train_dir}
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={"path": val_dir},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={"path": test_dir},
),
]
def _generate_examples(self, path):
"""Generate examples for each split."""
id = 0
for root, dirs, files in os.walk(path):
for file in files:
yield (
id,
{
"label": id,
},
)
id += 1