title: how to upload and read a zip file containing training and testing images data from google colab from my pc
body: <p>I am new to google colab. I am implementing a pretrained vgg16 and resnet50 model using pytorch, but I am unable to load my file and read it as it returns an error of no directory found </p>
  
  <p>I have uploaded the data through file also I have used to upload it using </p>
  
  <pre><code>from google.colab import files
  uploaded = files.upload()
  </code></pre>
  
  <p>The file got uploaded but when I tried to unzip it because it is a zip file using 
  <code>!unzip content/cropped_months</code>
  then it says </p>
  
  <blockquote>
    <p>no file found </p>
  </blockquote>
  
  <pre><code>import torch
  import torch.nn as nn
  import torch.optim as optim
  from torchvision.transforms import *
  from torch.optim import lr_scheduler
  from torch.autograd import Variable
  import numpy as np
  import torchvision
  from torchvision import datasets, models, transforms
  import matplotlib.pyplot as plt
  import time
  import os
  import copy
  
  from google.colab import files
  uploaded = files.upload()
  
  !unzip content/cropped_months 
  
  data_dir = 'content/cropped_months'
  ​
  #Define transforms for the training data and testing data
  train_transforms = transforms.Compose([transforms.RandomRotation(30),transforms.RandomResizedCrop(224),transforms.RandomHorizontalFlip(),transforms.ToTensor(),transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])
  ​
  test_transforms = transforms.Compose([transforms.Resize(256),transforms.CenterCrop(224),transforms.ToTensor(),transforms.Normalize([0.485, 0.456, 0.406],[0.229, 0.224, 0.225])])
  ​
  #pass transform here-in
  train_data = datasets.ImageFolder(data_dir + '/train', transform=train_transforms)
  test_data = datasets.ImageFolder(data_dir + '/test', transform=test_transforms)
  ​
  #data loaders
  trainloader = torch.utils.data.DataLoader(train_data, batch_size=8, shuffle=True)
  testloader = torch.utils.data.DataLoader(test_data, batch_size=8, shuffle=True)
  ​
  print("Classes: ")
  class_names = train_data.classes
  print(class_names)
  </code></pre>
  
  <p>first error </p>
  
  <blockquote>
    <p>unzip:  cannot find or open content/cropped_months,
    content/cropped_months.zip or content/cropped_months.ZIP.</p>
  </blockquote>
  
  <p>second error</p>
  
  <blockquote>
    <p>--------------------------------------------------------------------------- FileNotFoundError                         Traceback (most recent call
    last)  in ()
         16 
         17 #pass transform here-in
    ---> 18 train_data = datasets.ImageFolder(data_dir + '/train', transform=train_transforms)
         19 test_data = datasets.ImageFolder(data_dir + '/test', transform=test_transforms)
         20 </p>
    
    <p>2 frames
    /usr/local/lib/python3.6/dist-packages/torchvision/datasets/folder.py
    in _find_classes(self, dir)
        114         if sys.version_info >= (3, 5):
        115             # Faster and available in Python 3.5 and above
    --> 116             classes = [d.name for d in os.scandir(dir) if d.is_dir()]
        117         else:
        118             classes = [d for d in os.listdir(dir) if os.path.isdir(os.path.join(dir, d))]</p>
    
    <p>FileNotFoundError: [Errno 2] No such file or directory:
    'content/cropped_months (1)/train'</p>
  </blockquote>