File size: 1,716 Bytes
5f10b58
 
 
 
 
 
 
 
c0e2115
 
 
 
5f10b58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c0e2115
 
 
 
5f10b58
 
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
import datasets
import pyarrow.parquet as pq

class TrajectoryDataset(datasets.GeneratorBasedBuilder):
    def _info(self):
        return datasets.DatasetInfo(
            description="minecraft image-action data for world model",
            features=datasets.Features({
                "episode_id": datasets.Value("string"),  
                "frame_image": datasets.Value("string"),  
                "frame_actions": datasets.Sequence(datasets.Value("int32")),
                "step_id":datasets.Value("int32")
            }),
        )


    def _split_generators(self, dl_manager):
        
        base_url = "https://huggingface.co/datasets/Catill520/MC_data/resolve/main/data/"
        sub_paths = [
            "find-cave-Jul-28",  
        ]

        data_files = []
        for sub_path in sub_paths:
            subpath_url = f"{base_url}{sub_path}/"
            
            files = dl_manager.list_files(subpath_url)  
            for file in files:
                data_files.append(f"{subpath_url}{file}")

        
        downloaded_files = dl_manager.download(data_files)

        
        return [
            datasets.SplitGenerator(name="all_data", gen_kwargs={"filepaths": downloaded_files}),
        ]


    def _generate_examples(self, filepaths):
        for filepath in filepaths:
            
            table = pq.read_table(filepath)
            df = table.to_pandas()
            for idx, row in df.iterrows():
                yield idx, {
                    "episode_id": row["episode_id"],  
                    "frame_image": row["frame_image"],  
                    "frame_actions": row["frame_actions"],  
                    "step_id": row["step_id"],  
                }