alkzar90 commited on
Commit
5c7307b
1 Parent(s): 1041fa1

try csv parse

Browse files
Files changed (1) hide show
  1. NIH-Chest-X-ray-dataset.py +29 -3
NIH-Chest-X-ray-dataset.py CHANGED
@@ -3,6 +3,8 @@ import os
3
  import datasets
4
  from datasets.tasks import ImageClassification
5
 
 
 
6
 
7
  _HOMEPAGE = "https://nihcc.app.box.com/v/ChestXray-NIHCC"
8
 
@@ -22,7 +24,7 @@ The NIH Chest X-ray dataset consists of 100,000 de-identified images of chest x-
22
  The data is provided by the NIH Clinical Center and is available through the NIH download site: https://nihcc.app.box.com/v/ChestXray-NIHCC
23
  """
24
 
25
- _URLS = [
26
  'https://nihcc.box.com/shared/static/vfk49d74nhbxq3nqjg0900w5nvkorp5c.gz',
27
  'https://nihcc.box.com/shared/static/i28rlmbvmfjbl8p2n3ril0pptcmcu9d1.gz',
28
  'https://nihcc.box.com/shared/static/f1t00wrtdk94satdfb9olcolqx20z2jp.gz',
@@ -37,6 +39,17 @@ _URLS = [
37
  'https://nihcc.box.com/shared/static/ioqwiy20ihqwyr8pf4c24eazhh281pbu.gz'
38
  ]
39
 
 
 
 
 
 
 
 
 
 
 
 
40
  LABEL2IDX = {'No Finding': 0,
41
  'Atelactasis': 1,
42
  'Cardiomegaly': 2,
@@ -53,6 +66,9 @@ LABEL2IDX = {'No Finding': 0,
53
  'Pleural_Thickening': 13,
54
  'Hernia': 14}
55
 
 
 
 
56
  class XChest(datasets.GeneratorBasedBuilder):
57
  """NIH Image Chest X-ray dataset."""
58
 
@@ -63,7 +79,7 @@ class XChest(datasets.GeneratorBasedBuilder):
63
  {
64
  "image_file_path": datasets.Value("string"),
65
  "image": datasets.Image(),
66
- "labels": datasets.features.ClassLabel(names=list(LABEL2IDX.keys())),
67
  }
68
  ),
69
  supervised_keys=("image", "labels"),
@@ -72,7 +88,17 @@ class XChest(datasets.GeneratorBasedBuilder):
72
  task_templates=[ImageClassification(image_column="image",
73
  label_column="labels")],
74
  )
75
-
 
 
 
 
 
 
 
 
 
 
76
 
77
 
78
 
 
3
  import datasets
4
  from datasets.tasks import ImageClassification
5
 
6
+ from requests import get
7
+
8
 
9
  _HOMEPAGE = "https://nihcc.app.box.com/v/ChestXray-NIHCC"
10
 
 
24
  The data is provided by the NIH Clinical Center and is available through the NIH download site: https://nihcc.app.box.com/v/ChestXray-NIHCC
25
  """
26
 
27
+ _IMAGE_URLS2 = [
28
  'https://nihcc.box.com/shared/static/vfk49d74nhbxq3nqjg0900w5nvkorp5c.gz',
29
  'https://nihcc.box.com/shared/static/i28rlmbvmfjbl8p2n3ril0pptcmcu9d1.gz',
30
  'https://nihcc.box.com/shared/static/f1t00wrtdk94satdfb9olcolqx20z2jp.gz',
 
39
  'https://nihcc.box.com/shared/static/ioqwiy20ihqwyr8pf4c24eazhh281pbu.gz'
40
  ]
41
 
42
+ _IMAGE_URLS = [
43
+ 'https://huggingface.co/datasets/alkzar90/NIH-Chest-X-ray-dataset/resolve/main/dummy/0.0.0/images_001.tar.gz',
44
+ 'https://huggingface.co/datasets/alkzar90/NIH-Chest-X-ray-dataset/resolve/main/dummy/0.0.0/images_002.tar.gz'
45
+ ]
46
+
47
+ _URLS = {
48
+ 'train_val_list': 'https://huggingface.co/datasets/alkzar90/NIH-Chest-X-ray-dataset/raw/main/dummy/0.0.0/train_val_list.txt',
49
+ 'test_list': 'https://huggingface.co/datasets/alkzar90/NIH-Chest-X-ray-dataset/raw/main/dummy/0.0.0/test_list.txt',
50
+ 'image_urls': _IMAGE_URLS
51
+ }
52
+
53
  LABEL2IDX = {'No Finding': 0,
54
  'Atelactasis': 1,
55
  'Cardiomegaly': 2,
 
66
  'Pleural_Thickening': 13,
67
  'Hernia': 14}
68
 
69
+ _NAMES = list(LABEL2IDX.keys())
70
+
71
+
72
  class XChest(datasets.GeneratorBasedBuilder):
73
  """NIH Image Chest X-ray dataset."""
74
 
 
79
  {
80
  "image_file_path": datasets.Value("string"),
81
  "image": datasets.Image(),
82
+ "labels": datasets.features.ClassLabel(names=_NAMES),
83
  }
84
  ),
85
  supervised_keys=("image", "labels"),
 
88
  task_templates=[ImageClassification(image_column="image",
89
  label_column="labels")],
90
  )
91
+
92
+
93
+ def _split_generators(self, dl_manager):
94
+ data_files = dl_manager.download_and_extract(_URLS['image_urls'])
95
+ train_val_list = get(_URLS['train_val_list']).iter_lines()
96
+ train_val_list = set([x.decode('UTF8') for x in train_val_list])
97
+ print(train_val_list)
98
+ pass
99
+
100
+ def _generate_examples(self, files):
101
+ pass
102
 
103
 
104