File size: 2,690 Bytes
3afeebb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9c73c3
3afeebb
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os

import datasets
from datasets.tasks import ImageClassification


_HOMEPAGE = "https://nihcc.app.box.com/v/ChestXray-NIHCC"

_CITATION = """\
@ONLINE {beansdata,
    author="Xiaosong Wang, Yifan Peng, Le Lu, Zhiyong Lu, Mohammadhadi Bagheri, Ronald Summer",
    title="ChestX-ray8: Hospital-scale Chest X-ray Database and Benchmarks on Weakly-Supervised Classification and Localization of Common Thorax Diseases",
    month="January",
    year="2017",
    url="https://nihcc.app.box.com/v/ChestXray-NIHCC"
}
"""

_DESCRIPTION = """\
The NIH Chest X-ray dataset consists of 100,000 de-identified images of chest x-rays. The images are in PNG format.

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
"""

_URLS = [
    'https://nihcc.box.com/shared/static/vfk49d74nhbxq3nqjg0900w5nvkorp5c.gz',
    'https://nihcc.box.com/shared/static/i28rlmbvmfjbl8p2n3ril0pptcmcu9d1.gz',
    'https://nihcc.box.com/shared/static/f1t00wrtdk94satdfb9olcolqx20z2jp.gz',
    'https://nihcc.box.com/shared/static/0aowwzs5lhjrceb3qp67ahp0rd1l1etg.gz',
    'https://nihcc.box.com/shared/static/v5e3goj22zr6h8tzualxfsqlqaygfbsn.gz',
    'https://nihcc.box.com/shared/static/asi7ikud9jwnkrnkj99jnpfkjdes7l6l.gz',
    'https://nihcc.box.com/shared/static/jn1b4mw4n6lnh74ovmcjb8y48h8xj07n.gz',
    'https://nihcc.box.com/shared/static/tvpxmn7qyrgl0w8wfh9kqfjskv6nmm1j.gz',
    'https://nihcc.box.com/shared/static/upyy3ml7qdumlgk2rfcvlb9k6gvqq2pj.gz',
    'https://nihcc.box.com/shared/static/l6nilvfa9cg3s28tqv1qc1olm3gnz54p.gz',
    'https://nihcc.box.com/shared/static/hhq8fkdgvcari67vfhs7ppg2w6ni4jze.gz',
    'https://nihcc.box.com/shared/static/ioqwiy20ihqwyr8pf4c24eazhh281pbu.gz'
]

LABEL2IDX = {'No Finding': 0,
	     'Atelactasis': 1,
	     'Cardiomegaly': 2,
	     'Effusion': 3,
	     'Infiltration': 4,
	     'Mass': 5,
	     'Nodule': 6,
	     'Pneumonia': 7,
	     'Pneumothorax': 8,
  	     'Consolidation': 9,
	     'Edema': 10,
	     'Emphysema': 11,
	     'Fibrosis': 12,
	     'Pleural_Thickening': 13,
	     'Hernia': 14}

class XChest(datasets.GeneratorBasedBuilder):
	"""NIH Image Chest X-ray dataset."""

	def _info(self):
		return datasets.DatasetInfo(
		    description=_DESCRIPTION,
		    features=datasets.Features(
			{
			"image_file_path": datasets.Value("string"),
			"image": datasets.Image(),
			"labels": datasets.features.ClassLabel(names=list(LABEL2IDX.keys())),
			}
		    ),
		    supervised_keys=("image", "labels"),
		    homepage=_HOMEPAGE,
		    citation=_CITATION,
		    task_templates=[ImageClassification(image_column="image",
							label_column="labels")],
		)