text_plain_output_1.png
import cv2

import os

import pandas as pd

in_part1 = set(os.listdir('../input/skin-cancer-mnist-ham10000/ham10000_images_part_1'))

df = pd.read_csv('../input/skin-cancer-mnist-ham10000/HAM10000_metadata.csv')

x_train = []
y_train = []
lesions = set()
for index, row in df.iterrows():
    if row['lesion_id'] in lesions:
        continue
    lesions.add(row['lesion_id'])
    path = '../input/skin-cancer-mnist-ham10000/'
    if row['image_id'] + '.jpg' in in_part1:
        path += 'ham10000_images_part_1/' + row['image_id'] + '.jpg'
    else:
        path += 'ham10000_images_part_2/' + row['image_id'] + '.jpg'
    img = cv2.imread(path)
    img = cv2.resize(img, (100, 75))
    x_train.append(img)
    y_train.append(row['dx'])

y_train = pd.get_dummies(y_train)
y_train.head()