Upload aphantasia_drawing_dataset.py
Browse files
aphantasia_drawing_dataset.py
CHANGED
@@ -7,7 +7,7 @@ Original file is located at
|
|
7 |
https://colab.research.google.com/drive/1DYVroeFqoNK7DDiw_3OIczPeqEME-rbh
|
8 |
"""
|
9 |
|
10 |
-
|
11 |
|
12 |
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
13 |
#
|
@@ -27,13 +27,9 @@ Original file is located at
|
|
27 |
|
28 |
|
29 |
|
30 |
-
import base64
|
31 |
-
from PIL import Image
|
32 |
import pandas as pd
|
33 |
import numpy as np
|
34 |
import io
|
35 |
-
import json
|
36 |
-
import os
|
37 |
from typing import List
|
38 |
import datasets
|
39 |
import logging
|
@@ -87,7 +83,7 @@ class AphantasiaDrawingDataset(datasets.GeneratorBasedBuilder):
|
|
87 |
description=_DESCRIPTION,
|
88 |
features=datasets.Features({
|
89 |
"subject_id": datasets.Value("int32"),
|
90 |
-
"treatment": datasets.Value("string")
|
91 |
"demographics": {
|
92 |
"country": datasets.Value("string"),
|
93 |
"age": datasets.Value("int32"),
|
@@ -145,49 +141,10 @@ class AphantasiaDrawingDataset(datasets.GeneratorBasedBuilder):
|
|
145 |
image = Image.open(image_buffer)
|
146 |
return image
|
147 |
return None
|
148 |
-
|
149 |
with open(filepath, "rb") as subjects_file:
|
150 |
subjects_data = pd.read_parquet(subjects_file)
|
151 |
-
#idx = 0
|
152 |
for idx, sub_row in subjects_data.iterrows():
|
153 |
-
# for room in subjects_data[sub]["drawings"].keys():
|
154 |
-
# if subjects_data[sub]["drawings"][room]["perception"] != "":
|
155 |
-
# img_byt = base64.b64decode(subjects_data[sub]["drawings"][room]["perception"])
|
156 |
-
# img = Image.open(io.BytesIO(img_byt))
|
157 |
-
# subjects_data[sub]["drawings"][room]["perception"] = img
|
158 |
-
# else:
|
159 |
-
# subjects_data[sub]["drawings"][room]["perception"] = None
|
160 |
-
|
161 |
-
# if subjects_data[sub]["drawings"][room]["memory"] != "":
|
162 |
-
# img_byt = base64.b64decode(subjects_data[sub]["drawings"][room]["memory"])
|
163 |
-
# img = Image.open(io.BytesIO(img_byt))
|
164 |
-
# subjects_data[sub]["drawings"][room]["memory"] = img
|
165 |
-
# else:
|
166 |
-
# subjects_data[sub]["drawings"][room]["memory"] = None
|
167 |
-
|
168 |
-
# for room in subjects_data[sub]["image"].keys():
|
169 |
-
# img_byt = base64.b64decode(subjects_data[sub]["image"][room])
|
170 |
-
# img = Image.open(io.BytesIO(img_byt))
|
171 |
-
# subjects_data[sub]["image"][room] = img.resize((500,500))
|
172 |
-
# idx += 1
|
173 |
-
|
174 |
-
# try:
|
175 |
-
# age = int(sub_row["demographics.age"])
|
176 |
-
# except:
|
177 |
-
# age = -1
|
178 |
-
# try:
|
179 |
-
# art_ability = int(sub_row["demographics.art_ability"])
|
180 |
-
# except:
|
181 |
-
# art_ability = -1
|
182 |
-
# try:
|
183 |
-
# vviq_score = int(sub_row["demographics.vviq_score"])
|
184 |
-
# except:
|
185 |
-
# vviq_score = -1
|
186 |
-
# try:
|
187 |
-
# osiq_score = int(sub_row["demographics.osiq_score"])
|
188 |
-
# except:
|
189 |
-
# osiq_score = -1
|
190 |
-
# age = int(sub_row["demographics.age"]) if sub_row["demographics.age"] and sub_row["demographics.age"] is not np.nan else None
|
191 |
yield idx, {
|
192 |
"subject_id": sub_row["subject_id"],
|
193 |
"treatment": sub_row["treatment"],
|
@@ -224,4 +181,5 @@ class AphantasiaDrawingDataset(datasets.GeneratorBasedBuilder):
|
|
224 |
"livingroom": byt_to_image(sub_row["image.livingroom"]),
|
225 |
"bedroom": byt_to_image(sub_row["image.bedroom"])
|
226 |
}
|
227 |
-
}
|
|
|
|
7 |
https://colab.research.google.com/drive/1DYVroeFqoNK7DDiw_3OIczPeqEME-rbh
|
8 |
"""
|
9 |
|
10 |
+
|
11 |
|
12 |
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
13 |
#
|
|
|
27 |
|
28 |
|
29 |
|
|
|
|
|
30 |
import pandas as pd
|
31 |
import numpy as np
|
32 |
import io
|
|
|
|
|
33 |
from typing import List
|
34 |
import datasets
|
35 |
import logging
|
|
|
83 |
description=_DESCRIPTION,
|
84 |
features=datasets.Features({
|
85 |
"subject_id": datasets.Value("int32"),
|
86 |
+
"treatment": datasets.Value("string"),
|
87 |
"demographics": {
|
88 |
"country": datasets.Value("string"),
|
89 |
"age": datasets.Value("int32"),
|
|
|
141 |
image = Image.open(image_buffer)
|
142 |
return image
|
143 |
return None
|
144 |
+
|
145 |
with open(filepath, "rb") as subjects_file:
|
146 |
subjects_data = pd.read_parquet(subjects_file)
|
|
|
147 |
for idx, sub_row in subjects_data.iterrows():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
yield idx, {
|
149 |
"subject_id": sub_row["subject_id"],
|
150 |
"treatment": sub_row["treatment"],
|
|
|
181 |
"livingroom": byt_to_image(sub_row["image.livingroom"]),
|
182 |
"bedroom": byt_to_image(sub_row["image.bedroom"])
|
183 |
}
|
184 |
+
}
|
185 |
+
|