<jupyter_start><jupyter_text><jupyter_code>from google.colab import drive
drive.mount('/gdrive')
%cd /gdrive/'My Drive'/diabetic-retinopathy-resized/
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
import cv2
def loadImage(df):
    images = list()
    for i in range(len(df)):
            image_name = df.iloc[i]
            # print(image_name)
            img = cv2.imread(image_name)
            res = cv2.resize(img, dsize=(256, 256), interpolation=cv2.INTER_CUBIC)
            images.append(res)
    return images
firstTraining = pd.read_csv('omitValidationData_0_1.csv')
firstTraining.head()
firstTraining.info()
firstTraining['level(2)'].unique()
X_train, X_test, y_train, y_test = train_test_split(firstTraining['image'],firstTraining['level(2)'],test_size=0.20, random_state=42)
trainImages = loadImage(X_train)
testImages = loadImage(X_test)

trainImages = np.asarray(trainImages)
testImages = np.asarray(testImages)
print(trainImages.shape)
print(testImages.shape)
from keras.utils import to_categorical
y_train = to_categorical(y_train)
y_test = to_categorical(y_test)
np.save('./0x1/trainImages.npy', trainImages)
np.save('./0x1/testImages.npy', testImages)
np.save('./0x1/y_train.npy', y_train)
np.save('./0x1/y_test.npy', y_test)
print(trainImages.shape)
print(y_train.shape)
print(testImages.shape)
print(y_test.shape)<jupyter_output>(25650, 256, 256, 3)
(25650, 2)
(6413, 256, 256, 3)
(6413, 2)<jupyter_text>**Second Training**<jupyter_code>secondTraining = pd.read_csv('omitValidationData_1_2.csv')
secondTraining.head()
secondTraining.info()
secondTraining['level(3)'].value_counts()
secondTraining['level(3)'] = secondTraining['level(3)'].replace({1:0})
secondTraining['level(3)'] = secondTraining['level(3)'].replace({2:1})
secondTraining['level(3)'].value_counts()
X_train, X_test, y_train, y_test = train_test_split(secondTraining['image'],secondTraining['level(3)'],test_size=0.20, random_state=42)
trainImages = loadImage(X_train)
testImages = loadImage(X_test)

trainImages = np.asarray(trainImages)
testImages = np.asarray(testImages)
print(trainImages.shape)
print(testImages.shape)
from keras.utils import to_categorical
y_train = to_categorical(y_train)
y_test = to_categorical(y_test)
np.save('./1x2/trainImages.npy', trainImages)
np.save('./1x2/testImages.npy', testImages)
np.save('./1x2/y_train.npy', y_train)
np.save('./1x2/y_test.npy', y_test)
print(trainImages.shape)
print(y_train.shape)
print(testImages.shape)
print(y_test.shape)
# img = cv2.imread(X_train.iloc[0])
# res = cv2.resize(img, dsize=(256, 256), interpolation=cv2.INTER_CUBIC)
# img<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15242754986827248, 'fraction_numerical': 0.03650733910425292, 'mean_word_length': 6.7492711370262395, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '163731', 'license': 'MIT', 'n_tokens_mistral': 1057, 'n_tokens_neox': 989, 'n_words': 149, 'path': 'notebooks/3.generateNPY.ipynb', 'repo_name': 'muhdlaziem/DR', 'size': '2657'}