kernelfea8793d3e

From: https://www.kaggle.com/chrisevans/kernelfea8793d3e

Author: ChrisEvans

In [1]:
# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in 

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

# Input data files are available in the "../input/" directory.
# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory

import os
print(os.listdir("../input"))

# Any results you write to the current directory are saved as output.
['kaggle_sample_submission.csv', 'train_val2019', 'val2019.json', 'train2019.json', 'test2019.json', 'test2019']
In [2]:
cd train_val2019
[Errno 2] No such file or directory: 'train_val2019'
/kaggle/working
In [3]:
!ls Birds/202/0046f8c09d5d6acaa78baeffb2ba5c43.jpg
ls: cannot access 'Birds/202/0046f8c09d5d6acaa78baeffb2ba5c43.jpg': No such file or directory
In [4]:
from matplotlib.image import imread
import numpy as np

data = imread('Birds/202/0046f8c09d5d6acaa78baeffb2ba5c43.jpg')
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-4-6b778f749de4> in <module>()
      2 import numpy as np
      3 
----> 4 data = imread('Birds/202/0046f8c09d5d6acaa78baeffb2ba5c43.jpg')
      5 

/opt/conda/lib/python3.6/site-packages/matplotlib/image.py in imread(fname, format)
   1349                              'with Pillow installed matplotlib can handle '
   1350                              'more images' % list(handlers))
-> 1351         with Image.open(fname) as image:
   1352             return pil_to_array(image)
   1353 

/opt/conda/lib/python3.6/site-packages/PIL/Image.py in open(fp, mode)
   2546 
   2547     if filename:
-> 2548         fp = builtins.open(filename, "rb")
   2549         exclusive_fp = True
   2550 

FileNotFoundError: [Errno 2] No such file or directory: 'Birds/202/0046f8c09d5d6acaa78baeffb2ba5c43.jpg'
In [5]:
data
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-c5d84736ba45> in <module>()
----> 1 data

NameError: name 'data' is not defined
In [6]:
from PIL import Image

img = Image.fromarray(data, 'RGB')
img
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-6-e3d8ff92350a> in <module>()
      1 from PIL import Image
      2 
----> 3 img = Image.fromarray(data, 'RGB')
      4 img

NameError: name 'data' is not defined