Skip to content

Instantly share code, notes, and snippets.

@fabsta
Created August 28, 2016 20:27
Show Gist options
  • Save fabsta/9689e7bb39984def6309c55735eed2e6 to your computer and use it in GitHub Desktop.
Save fabsta/9689e7bb39984def6309c55735eed2e6 to your computer and use it in GitHub Desktop.

Exceptions

try - except

try:
    image_data = (ndimage.imread(image_file).astype(float) - 
                    pixel_depth / 2) / pixel_depth
      if image_data.shape != (image_size, image_size):
        raise Exception('Unexpected image shape: %s' % str(image_data.shape))
      dataset[num_images, :, :] = image_data
      num_images = num_images + 1
except IOError as e:
      print('Could not read:', image_file, ':', e, '- it\'s ok, skipping.')            

image size differs

if image_data.shape != (image_size, image_size):
        raise Exception('Unexpected image shape: %s' % str(image_data.shape))
        
        
except IOError as e:
      print('Could not read:', image_file, ':', e, '- it\'s ok, skipping.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment