Alexandr Bolotin commited on
Commit ·
48a3baa
1
Parent(s): ba84249
delete
Browse files- parquet_push_to_hub.py +0 -65
- xray_chest.csv +0 -98
parquet_push_to_hub.py
DELETED
|
@@ -1,65 +0,0 @@
|
|
| 1 |
-
import io
|
| 2 |
-
import os
|
| 3 |
-
import datasets
|
| 4 |
-
import traceback
|
| 5 |
-
|
| 6 |
-
from PIL import Image
|
| 7 |
-
from datasets import Features, Dataset
|
| 8 |
-
|
| 9 |
-
def create_features():
|
| 10 |
-
features = Features(
|
| 11 |
-
{
|
| 12 |
-
'image': datasets.Image(),
|
| 13 |
-
"type": datasets.Value("string"),
|
| 14 |
-
}
|
| 15 |
-
)
|
| 16 |
-
return features
|
| 17 |
-
|
| 18 |
-
def image_to_bytes(image_path):
|
| 19 |
-
image = Image.open(image_path)
|
| 20 |
-
|
| 21 |
-
image_data = io.BytesIO()
|
| 22 |
-
image.save(image_data, format='PNG')
|
| 23 |
-
|
| 24 |
-
img_data = image_data.getvalue()
|
| 25 |
-
|
| 26 |
-
return img_data
|
| 27 |
-
|
| 28 |
-
def main():
|
| 29 |
-
current_directory = os.path.dirname(os.path.realpath(__file__))
|
| 30 |
-
|
| 31 |
-
files_folder = 'files'
|
| 32 |
-
files_folder_path = os.path.join(current_directory, files_folder)
|
| 33 |
-
|
| 34 |
-
dataset_dict = {
|
| 35 |
-
'image': [],
|
| 36 |
-
"type": [],
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
for root, dirs, files in os.walk(files_folder_path):
|
| 40 |
-
for file in files:
|
| 41 |
-
|
| 42 |
-
if file.lower().endswith(('.jpg', '.jpeg')):
|
| 43 |
-
file_path = os.path.join(root, file)
|
| 44 |
-
img_data = image_to_bytes(file_path)
|
| 45 |
-
dataset_dict['image'].append(img_data)
|
| 46 |
-
dataset_dict['type'].append(os.path.basename(root))
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
# print('dataset_dict', dataset_dict)
|
| 50 |
-
# print('features', create_features())
|
| 51 |
-
|
| 52 |
-
try:
|
| 53 |
-
dataset = Dataset.from_dict(dataset_dict, features=create_features())
|
| 54 |
-
except Exception as e:
|
| 55 |
-
traceback.print_exc()
|
| 56 |
-
# print(e)
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
os.environ["HF_HOME"] = "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"
|
| 60 |
-
|
| 61 |
-
dataset.push_to_hub('TrainingDataPro/chest-x-rays')
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
if __name__ == "__main__":
|
| 65 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xray_chest.csv
DELETED
|
@@ -1,98 +0,0 @@
|
|
| 1 |
-
dcm,jpg,type
|
| 2 |
-
/abscess/0.dcm,/abscess/0.jpg,abscess
|
| 3 |
-
/abscess/1.dcm,/abscess/1.jpg,abscess
|
| 4 |
-
/abscess/2.dcm,/abscess/2.jpg,abscess
|
| 5 |
-
/abscess/3.dcm,/abscess/3.jpg,abscess
|
| 6 |
-
/abscess/4.dcm,/abscess/4.jpg,abscess
|
| 7 |
-
/abscess/5.dcm,/abscess/5.jpg,abscess
|
| 8 |
-
/abscess/6.dcm,/abscess/6.jpg,abscess
|
| 9 |
-
/abscess/7.dcm,/abscess/7.jpg,abscess
|
| 10 |
-
/abscess/8.dcm,/abscess/8.jpg,abscess
|
| 11 |
-
/ards/0.dcm,/ards/0.jpg,ards
|
| 12 |
-
/ards/1.dcm,/ards/1.jpg,ards
|
| 13 |
-
/atelectasis/0.dcm,/atelectasis/0.jpg,atelectasis
|
| 14 |
-
/atelectasis/1.dcm,/atelectasis/1.jpg,atelectasis
|
| 15 |
-
/atelectasis/2.dcm,/atelectasis/2.jpg,atelectasis
|
| 16 |
-
/atelectasis/3.dcm,/atelectasis/3.jpg,atelectasis
|
| 17 |
-
/atelectasis/4.dcm,/atelectasis/4.jpg,atelectasis
|
| 18 |
-
/atelectasis/5.dcm,/atelectasis/5.jpg,atelectasis
|
| 19 |
-
/atelectasis/6.dcm,/atelectasis/6.jpg,atelectasis
|
| 20 |
-
/atherosclerosis_of_the_aorta/0.dcm,/atherosclerosis_of_the_aorta/0.jpg,atherosclerosis of the aorta
|
| 21 |
-
/atherosclerosis_of_the_aorta/1.dcm,/atherosclerosis_of_the_aorta/1.jpg,atherosclerosis of the aorta
|
| 22 |
-
/atherosclerosis_of_the_aorta/2.dcm,/atherosclerosis_of_the_aorta/2.jpg,atherosclerosis of the aorta
|
| 23 |
-
/atherosclerosis_of_the_aorta/3.dcm,/atherosclerosis_of_the_aorta/3.jpg,atherosclerosis of the aorta
|
| 24 |
-
/atherosclerosis_of_the_aorta/4.dcm,/atherosclerosis_of_the_aorta/4.jpg,atherosclerosis of the aorta
|
| 25 |
-
/atherosclerosis_of_the_aorta/5.dcm,/atherosclerosis_of_the_aorta/5.jpg,atherosclerosis of the aorta
|
| 26 |
-
/cardiomegaly/0.dcm,/cardiomegaly/0.jpg,cardiomegaly
|
| 27 |
-
/cardiomegaly/1.dcm,/cardiomegaly/1.jpg,cardiomegaly
|
| 28 |
-
/cardiomegaly/2.dcm,/cardiomegaly/2.jpg,cardiomegaly
|
| 29 |
-
/cardiomegaly/3.dcm,/cardiomegaly/3.jpg,cardiomegaly
|
| 30 |
-
/cardiomegaly/4.dcm,/cardiomegaly/4.jpg,cardiomegaly
|
| 31 |
-
/cardiomegaly/5.dcm,/cardiomegaly/5.jpg,cardiomegaly
|
| 32 |
-
/cardiomegaly/6.dcm,/cardiomegaly/6.jpg,cardiomegaly
|
| 33 |
-
/cardiomegaly/7.dcm,/cardiomegaly/7.jpg,cardiomegaly
|
| 34 |
-
/emphysema/0.dcm,/emphysema/0.jpg,emphysema
|
| 35 |
-
/emphysema/1.dcm,/emphysema/1.jpg,emphysema
|
| 36 |
-
/emphysema/2.dcm,/emphysema/2.jpg,emphysema
|
| 37 |
-
/emphysema/3.dcm,/emphysema/3.jpg,emphysema
|
| 38 |
-
/emphysema/4.dcm,/emphysema/4.jpg,emphysema
|
| 39 |
-
/fracture/0.dcm,/fracture/0.jpg,fracture
|
| 40 |
-
/fracture/1.dcm,/fracture/1.jpg,fracture
|
| 41 |
-
/fracture/2.dcm,/fracture/2.jpg,fracture
|
| 42 |
-
/fracture/3.dcm,/fracture/3.jpg,fracture
|
| 43 |
-
/fracture/4.dcm,/fracture/4.jpg,fracture
|
| 44 |
-
/fracture/5.dcm,/fracture/5.jpg,fracture
|
| 45 |
-
/hydropneumothorax/0.dcm,/hydropneumothorax/0.jpg,hydropneumothorax
|
| 46 |
-
/hydropneumothorax/1.dcm,/hydropneumothorax/1.jpg,hydropneumothorax
|
| 47 |
-
/hydropneumothorax/2.dcm,/hydropneumothorax/2.jpg,hydropneumothorax
|
| 48 |
-
/hydropneumothorax/3.dcm,/hydropneumothorax/3.jpg,hydropneumothorax
|
| 49 |
-
/hydropneumothorax/4.dcm,/hydropneumothorax/4.jpg,hydropneumothorax
|
| 50 |
-
/hydropneumothorax/5.dcm,/hydropneumothorax/5.jpg,hydropneumothorax
|
| 51 |
-
/hydropneumothorax/6.dcm,/hydropneumothorax/6.jpg,hydropneumothorax
|
| 52 |
-
/hydropneumothorax/7.dcm,/hydropneumothorax/7.jpg,hydropneumothorax
|
| 53 |
-
/hydropneumothorax/8.dcm,/hydropneumothorax/8.jpg,hydropneumothorax
|
| 54 |
-
/hydrothorax/0.dcm,/hydrothorax/0.jpg,hydrothorax
|
| 55 |
-
/hydrothorax/1.dcm,/hydrothorax/1.jpg,hydrothorax
|
| 56 |
-
/hydrothorax/2.dcm,/hydrothorax/2.jpg,hydrothorax
|
| 57 |
-
/hydrothorax/3.dcm,/hydrothorax/3.jpg,hydrothorax
|
| 58 |
-
/hydrothorax/4.dcm,/hydrothorax/4.jpg,hydrothorax
|
| 59 |
-
/pneumonia/0.dcm,/pneumonia/0.jpg,pneumonia
|
| 60 |
-
/pneumonia/1.dcm,/pneumonia/1.jpg,pneumonia
|
| 61 |
-
/pneumonia/2.dcm,/pneumonia/2.jpg,pneumonia
|
| 62 |
-
/pneumonia/3.dcm,/pneumonia/3.jpg,pneumonia
|
| 63 |
-
/pneumonia/4.dcm,/pneumonia/4.jpg,pneumonia
|
| 64 |
-
/pneumosclerosis/0.dcm,/pneumosclerosis/0.jpg,pneumosclerosis
|
| 65 |
-
/pneumosclerosis/1.dcm,/pneumosclerosis/1.jpg,pneumosclerosis
|
| 66 |
-
/pneumosclerosis/2.dcm,/pneumosclerosis/2.jpg,pneumosclerosis
|
| 67 |
-
/pneumosclerosis/3.dcm,/pneumosclerosis/3.jpg,pneumosclerosis
|
| 68 |
-
/post_inflammatory_changes/0.dcm,/post_inflammatory_changes/0.jpg,post-inflammatory changes
|
| 69 |
-
/post_inflammatory_changes/1.dcm,/post_inflammatory_changes/1.jpg,post-inflammatory changes
|
| 70 |
-
/post_inflammatory_changes/2.dcm,/post_inflammatory_changes/2.jpg,post-inflammatory changes
|
| 71 |
-
/post_inflammatory_changes/3.dcm,/post_inflammatory_changes/3.jpg,post-inflammatory changes
|
| 72 |
-
/post_inflammatory_changes/4.dcm,/post_inflammatory_changes/4.jpg,post-inflammatory changes
|
| 73 |
-
/post_inflammatory_changes/5.dcm,/post_inflammatory_changes/5.jpg,post-inflammatory changes
|
| 74 |
-
/post_inflammatory_changes/6.dcm,/post_inflammatory_changes/6.jpg,post-inflammatory changes
|
| 75 |
-
/post_traumatic_ribs_deformation/0.dcm,/post_traumatic_ribs_deformation/0.jpg,post-traumatic ribs deformation
|
| 76 |
-
/post_traumatic_ribs_deformation/1.dcm,/post_traumatic_ribs_deformation/1.jpg,post-traumatic ribs deformation
|
| 77 |
-
/post_traumatic_ribs_deformation/2.dcm,/post_traumatic_ribs_deformation/2.jpg,post-traumatic ribs deformation
|
| 78 |
-
/post_traumatic_ribs_deformation/3.dcm,/post_traumatic_ribs_deformation/3.jpg,post-traumatic ribs deformation
|
| 79 |
-
/post_traumatic_ribs_deformation/4.dcm,/post_traumatic_ribs_deformation/4.jpg,post-traumatic ribs deformation
|
| 80 |
-
/sarcoidosis/0.dcm,/sarcoidosis/0.jpg,sarcoidosis
|
| 81 |
-
/sarcoidosis/1.dcm,/sarcoidosis/1.jpg,sarcoidosis
|
| 82 |
-
/sarcoidosis/2.dcm,/sarcoidosis/2.jpg,sarcoidosis
|
| 83 |
-
/sarcoidosis/3.dcm,/sarcoidosis/3.jpg,sarcoidosis
|
| 84 |
-
/sarcoidosis/4.dcm,/sarcoidosis/4.jpg,sarcoidosis
|
| 85 |
-
/sarcoidosis/5.dcm,/sarcoidosis/5.jpg,sarcoidosis
|
| 86 |
-
/scoliosis/0.dcm,/scoliosis/0.jpg,scoliosis
|
| 87 |
-
/scoliosis/1.dcm,/scoliosis/1.jpg,scoliosis
|
| 88 |
-
/scoliosis/2.dcm,/scoliosis/2.jpg,scoliosis
|
| 89 |
-
/scoliosis/3.dcm,/scoliosis/3.jpg,scoliosis
|
| 90 |
-
/tuberculosis/0.dcm,/tuberculosis/0.jpg,tuberculosis
|
| 91 |
-
/tuberculosis/1.dcm,/tuberculosis/1.jpg,tuberculosis
|
| 92 |
-
/tuberculosis/2.dcm,/tuberculosis/2.jpg,tuberculosis
|
| 93 |
-
/tuberculosis/3.dcm,/tuberculosis/3.jpg,tuberculosis
|
| 94 |
-
/tuberculosis/4.dcm,/tuberculosis/4.jpg,tuberculosis
|
| 95 |
-
/venous_congestion/0.dcm,/venous_congestion/0.jpg,venous congestion
|
| 96 |
-
/venous_congestion/1.dcm,/venous_congestion/1.jpg,venous congestion
|
| 97 |
-
/venous_congestion/2.dcm,/venous_congestion/2.jpg,venous congestion
|
| 98 |
-
/venous_congestion/3.dcm,/venous_congestion/3.jpg,venous congestion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|