Я новичок как в python, так и в глубоком обучении. Я использую код для обнаружения рака легких. Я продолжаю получать сообщение об ошибке 'DataFrame' object has no attribute 'get_value'
, и я не знаю, где я ошибаюсь ...
Здесь есть похожие вопросы -> link1 link2 Но ни один из них не помог.
Вот мой код
train_data = []
test_data = []
for num, patient in enumerate(patients):
if num%50 == 0:
print(num)
try:
img_data, label = process_data(patient, data_labels, img_pxl_size=IMG_PXL_SIZE, hm_slices=HM_SLICES)
train_data.append([img_data,label])
print(img_data.shape, label)
except KeyError as e:
test_data.append([img_data])
print(img_data.shape , '\tThis is unlabeled data')
np.save('traindata-{}-{}-{}.npy'.format(IMG_PXL_SIZE,IMG_PXL_SIZE,HM_SLICES), train_data)
np.save('testdata-{}-{}-{}.npy'.format(IMG_PXL_SIZE,IMG_PXL_SIZE,HM_SLICES), test_data)
print('Finished processing')
, и это ошибка, которую я получаю
AttributeError Traceback (most recent call last)
<ipython-input-15-3cc0d9dbeb3c> in <module>()
9
10 try:
---> 11 img_data, label = process_data(patient, data_labels, img_pxl_size=IMG_PXL_SIZE, hm_slices=HM_SLICES)
12 train_data.append([img_data,label])
13 print(img_data.shape, label)
----------------------------------------------------------------------------------------------
/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in __getattr__(self, name)
5272 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5273 return self[name]
-> 5274 return object.__getattribute__(self, name)
5275
5276 def __setattr__(self, name: str, value) -> None:
AttributeError: 'DataFrame' object has no attribute 'get_value'
Определение process_data
здесь
# Function to process data
def process_data(patient, data_labels, img_pxl_size=20, hm_slices=20, vizualize = False):
label = data_labels.get_value(patient,'cancer')
path = data_dir + patient
slices = [dicom.read_file(path + '/' + s) for s in os.listdir(path)]
slices.sort(key = lambda x: float(x.ImagePositionPatient[2]))
#print(len(slices), label)
#print(slices[0])
#plt.imshow(slices[0].pixel_array)
#plt.show()
new_slices = []
slices = [cv2.resize(np.array(each_slice.pixel_array),(IMG_PXL_SIZE,IMG_PXL_SIZE)) for each_slice in slices]
chunk_sizes = math.ceil(len(slices) / HM_SLICES)
for slice_chunk in chunks(slices,chunk_sizes):
slice_chunk = list(map(mean, zip(*slice_chunk)))
new_slices.append(slice_chunk)
if len(new_slices) == HM_SLICES-1:
new_slices.append(new_slices[-1])
if len(new_slices) == HM_SLICES-2:
new_slices.append(new_slices[-1])
new_slices.append(new_slices[-1])
if len(new_slices) == HM_SLICES+2:
new_val = list(map(mean, zip(*[new_slices[HM_SLICES-1],new_slices[HM_SLICES]])))
del new_slices[HM_SLICES]
new_slices[HM_SLICES-1] = new_val
if len(new_slices) == HM_SLICES+1:
new_val = list(map(mean, zip(*[new_slices[HM_SLICES-1],new_slices[HM_SLICES]])))
del new_slices[HM_SLICES]
new_slices[HM_SLICES-1] = new_val
if vizualize:
fig = plt.figure()
for num,each_slice in enumerate(slices[:12]):
y = fig.add_subplot(4,5,num+1)
#new_image = scipy.misc.imresize(np.array(each_slice.pixel_array),(IMG_PXL_SIZE,IMG_PXL_SIZE))
#y.imshow(slices[0].pixel_array)
#y.imshow(each_slice)
plt.show()
if label == 1: label = np.array([0,1])
elif label == 0: label = np.array([1,0])
return np.array(new_slices), label
Было бы очень полезно, если бы кто-нибудь мог помочь мне решить эту проблему.