def _fetch_asirra(partial_path, image_count=1000):
    files_path = os.path.join(partial_path, 'PetImages')
    cat_files_path = os.path.join(files_path, 'Cat', '*.jpg')
    dog_files_path = os.path.join(files_path, 'Dog', '*.jpg')

    def get_file_number(f):
        fname = os.path.split(f)[-1]
        return int(fname[:-4])

    cat_files = sorted(glob(cat_files_path), key=get_file_number)
    dog_files = sorted(glob(dog_files_path), key=get_file_number)
    X = np.zeros((image_count, 231, 231, 3), dtype='uint8')
    y = np.zeros(image_count)
    count = 0
    for f in cat_files:
        try:
            # Some of these files are not reading right...
            im = Image.open(f, 'r')
            X[count] = np.array(im.resize((231, 231)))
            y[count] = 0.
            count += 1
        except:
            continue
        if count >= image_count // 2:
            break

    for f in dog_files:
        try:
            # Some of these files are not reading right...
            im = Image.open(f, 'r')
            X[count] = np.array(im.resize((231, 231)))
            y[count] = 1.
            count += 1
        except:
            continue
        if count >= image_count:
            break
    return X, y
dataset/ETHPy150Open sklearn-theano/sklearn-theano/sklearn_theano/datasets/asirra.py/_fetch_asirra/original