Update README.md
Browse filesadd usage python scripts
README.md
CHANGED
@@ -22,3 +22,38 @@ dataset_info:
|
|
22 |
download_size: 32870167
|
23 |
dataset_size: 77424914
|
24 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
download_size: 32870167
|
23 |
dataset_size: 77424914
|
24 |
---
|
25 |
+
|
26 |
+
Usage:
|
27 |
+
```python
|
28 |
+
from dataclasses import dataclass
|
29 |
+
import datasets
|
30 |
+
|
31 |
+
@dataclass
|
32 |
+
class ReplaceImagePath():
|
33 |
+
path_map: {}
|
34 |
+
def __call__(self, features):
|
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 = "/mnt/bn/hri-lq/datasets/coco"
|
42 |
+
path_visdial = "/mnt/bn/data-lq/datasets-hf/hub/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 |
+
```
|