jxu124 commited on
Commit
b966f33
1 Parent(s): c04a7f9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +11 -21
README.md CHANGED
@@ -28,6 +28,16 @@ Usage:
28
  from dataclasses import dataclass
29
  import datasets
30
 
 
 
 
 
 
 
 
 
 
 
31
  @dataclass
32
  class ReplaceImagePath():
33
  path_map: {}
@@ -35,25 +45,5 @@ class ReplaceImagePath():
35
  for k, v in self.path_map.items():
36
  features['image'] = features['image'].replace(k, v)
37
  return features
38
-
39
- # setting
40
- ds_visdial = datasets.load_dataset('jxu124/visdial')
41
- path_coco = "/path/to/coco"
42
- path_visdial = "/path/to/jxu124/visdial"
43
-
44
- # 解压图片压缩文件(直接内存映射,不消耗时间)
45
- dl_manager = datasets.DownloadManager()
46
- path_visdial_dict = datasets.DownloadManager().download_and_extract({
47
- "test": f"{path_visdial}/data/VisualDialog_test2018.zip",
48
- "validation": f"{path_visdial}/data/VisualDialog_val2018.zip"
49
- })
50
- # 设置路径映射
51
- path_map = {
52
- "coco": path_coco,
53
- "visdial/VisualDialog_test2018": f"{path_visdial_dict['test']}/VisualDialog_test2018",
54
- "visdial/VisualDialog_val2018": f"{path_visdial_dict['validation']}/VisualDialog_val2018"
55
- }
56
-
57
- # apply your datasets
58
- ds_visdial = ds_visdial.map(ReplaceImagePath(path_map)).cast_column("image", datasets.Image())
59
  ```
 
28
  from dataclasses import dataclass
29
  import datasets
30
 
31
+ # load and path setting
32
+ ds_visdial = datasets.load_dataset('jxu124/visdial')
33
+ path_map = {
34
+ "coco/train2014": f"/datasets/coco/train2014",
35
+ "coco/val2014": f"/datasets/coco/val2014",
36
+ "visdial/VisualDialog_test2018": f"/datasets/visdial/VisualDialog_test2018",
37
+ "visdial/VisualDialog_val2018": f"/datasets/visdial/VisualDialog_val2018"
38
+ }
39
+
40
+ # apply to your datasets
41
  @dataclass
42
  class ReplaceImagePath():
43
  path_map: {}
 
45
  for k, v in self.path_map.items():
46
  features['image'] = features['image'].replace(k, v)
47
  return features
48
+ ds_visdial = ds_visdial.map(ReplaceImagePath(path_map=path_map)).cast_column("image", datasets.Image())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  ```