Kernel never stops when I input next function

I try to create a custom dataset.

# -*- coding: utf-8 -*-
Created on Sun Apr 21 22:00:45 2019

@author: melik

import pandas as pd
data = pd.read_csv('data.csv')
import requests
import re
import numpy as np
from import Dataset
from torchvision import transforms
import torch
from torchvision import transforms, datasets
# python2 script to download all images in a given url
# use: python http://url.where.images.are
import os
from PIL import Image
import requests
from io import BytesIO
a = []
def web(x):
    for i,each in enumerate(x):
            response = requests.get(each)
            img =
        if i == 100:
folder = os.path.join('images')
images = []

for i,filename in enumerate(os.listdir(folder)):
    if i ==99:
label = np.linspace(0,99,100)
df = pd.DataFrame({'images':images,'labels':label})
df.to_csv('out.csv', encoding='utf-8', index=False)

class CustomDatasetFromImages(Dataset):
    def __init__(self, csv_path):
            csv_path (string): path to csv file
            img_path (string): path to the folder where images are
            transform: pytorch transforms for transforms and tensor conversion
        # Transforms
        self.crop = transforms.RandomSizedCrop(48)
        self.to_tensor = transforms.ToTensor()
        # Read the csv file
        self.data_info = pd.read_csv(csv_path,sep=',')
        # First column contains the image paths
        self.image_arr = np.asarray(self.data_info.iloc[:, 0])
        # Second column is the labels
        self.label_arr = np.asarray(self.data_info.iloc[:, 1])
        # Third column is for an operation indicator
        self.data_len = len(self.data_info.index)

    def __getitem__(self, index):
        # Get image name from the pandas df
        single_image_name = self.image_arr[index]
        # Open image
        img_as_img =
        # Check if there is an operation
        img_as_tensor = self.to_tensor(img_as_img)
        img_as_tensor = img_as_tensor[1,:,:]
        img_as_tensor = img_as_tensor.unsqueeze(0)

        # Get label(class) of the image based on the cropped pandas column
        single_image_label = self.label_arr[index]

        return (img_as_tensor, single_image_label)

    def __len__(self):
        return self.data_len

a = CustomDatasetFromImages('out.csv')
dataset_loader =,
                                             batch_size=4, shuffle=True,

** I can succesfully run iter but when I input kernel
never stops.

Thanks for your help**