<jupyter_start><jupyter_text>Load Data<jupyter_code>import glob, os 
from skimage import io, transform
import numpy as np
import matplotlib.pyplot as plt
path="images/"
imlist= glob.glob(os.path.join(path, '*.jpg'))
def dataset(file_list,size=(300,180),flattened=False):
	data = []
	for i, file in enumerate(file_list):
		image = io.imread(file)
		image = transform.resize(image, size, mode='constant')
		if flattened:
			image = image.flatten()

		data.append(image)

	labels = [1 if f.split("/")[-1][0] == 'P' else 0 for f in file_list]

	return np.array(data), np.array(labels)
# Load the dataset (may take a few seconds)
X,y=dataset(imlist)
# X has the following structure: X[imageid, y,x,channel]
print('X: ',X.shape)  # data
print('y: ',y.shape)  # target
print('Class 0: ',sum(y==0))
print('Class 1: ',sum(y==1))
print('Total  : ',len(y))
print(y)
%matplotlib inline 
fig, axes = plt.subplots(1,2)
k=0
plt.sca(axes[0])
plt.imshow(X[k])
plt.title('img {} - class {}'.format(k, y[k]))

k=400
plt.sca(axes[1])
plt.imshow(X[k])
plt.title('img {} - class {}'.format(k, y[k]));<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.194043321299639, 'fraction_numerical': 0.019855595667870037, 'mean_word_length': 5.410404624277457, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '350737', 'license': 'zlib-acknowledgement', 'n_tokens_mistral': 471, 'n_tokens_neox': 441, 'n_words': 104, 'path': 'Read-skimage.ipynb', 'repo_name': 'sirasatinithyanand/deep-learning-course-project-1', 'size': '1108'}