trans=transforms.ToTensor()
def convert_to_tensor(X,y,name_of_fish,dic):
    images=glob.glob("fishes/"+ name_of_fish + "/*jpg")
    for image in images:
        image=Image.open(image).resize((720,1280),Image.ANTIALIAS)
        x=trans(image)
        image.close()
        X+=[x]
        y+=[dic[name_of_fish]]
dic={"ALB":1,"BET":2,"DOL":3,"LAG":4,"Nof":5,"OTHER":6,"SHARK":7,"YFT":8}
X=[]

y=[]
convert_to_tensor(X,y,"ALB",dic)

Running this script gives me error that not enough memory is available and slows down my computer a lot. Basically i want to convert all images to tensor so that i can apply CNN.
Whats the problem?