皮肤癌分类–基于Keras的卷积神经网络实现分类
数据集中的病理图片包含3个类别
melanoma(黑素瘤)nevus(痣) seborrheickeratosis(脂溢性角化病)
from sklearn import datasets
import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from keras.preprocessing import image as image2
from tqdm import tqdm
from PIL import ImageFile
plt.style.use('default')
from matplotlib import image
def plot_image(filename_list):
fig,axes=plt.subplots(nrows=3,ncols=3)
fig.set_size_inches(10,9)
random_9_nums=np.random.choice(len(filename_list),9)
random_9_imgs=filename_list[random_9_nums]
print(random_9_imgs)
imgname_list=[]
for imgpath in random_9_imgs:
imgname=imgpath[len(datasets_path)+1:]
imgname=imgname[:imgname.find('/')]
imgname_list.append(imgname)
index=0
for row_index in range(3):
for col_index in range(3):
img=image.imread(random_9_imgs[index])
ax=axes[row_index,col_index]
ax.imshow(img)
ax.set_xlabel(imgname_list[index])
index+=1
plt.show()
print("查看病理图片的大小:")
for i, img_path in enumerate(random_9_imgs):
print_img_shape(i, img_path)
def get_data(path):
data=datasets.load_files