In [22]:
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
plt.style.use('ggplot')


from os import getcwd
from os import listdir
from os.path import isfile, join, isdir


mypath = '/Users/jdstokes/repos/fish/'

trainPath = join(mypath,'train')
groupNames = [f for f in listdir(trainPath) if isdir(join(trainPath, f))]

In [9]:
import numpy as np
import pandas as pd

groupData = pd.DataFrame ({'group': groupNames})
# groupData.test = 'test'

In [10]:
# groupData.ix[0,'foo'] = 99
groupData


Out[10]:
group
0 ALB
1 BET
2 DOL
3 LAG
4 NoF
5 OTHER
6 SHARK
7 YFT

In [131]:
fishPaths[groupData['group'][0]][0]


Out[131]:
'/Users/jdstokes/repos/fish/train/ALB/img_00003.jpg'

In [143]:
fishPaths = dict.fromkeys(groupData['group'])

for idx,g in enumerate(groupNames):
    fileNames = [f for f in listdir(join(trainPath,g)) if isfile(join(trainPath,g, f))]
    for i,f in enumerate(fileNames):
        fileNames[i] = join(trainPath,g,f)
        
    groupData.ix[idx,'num files'] = int(len(fileNames))
    fishPaths[g] = fileNames
    
    
groupData


Out[143]:
group num files
0 ALB 1719.0
1 BET 200.0
2 DOL 117.0
3 LAG 67.0
4 NoF 465.0
5 OTHER 299.0
6 SHARK 176.0
7 YFT 734.0

In [142]:
# groupData = groupData.drop('bar', 1)

In [137]:
import skimage
from skimage import io

camera = io.imread(fishPaths[groupData['group'][0]][0])

plt.figure(figsize=(5, 5))
plt.imshow(camera, cmap='gray', interpolation='nearest')
plt.axis('off')
plt.tight_layout()
plt.show()

print(camera.shape[0:2])


(720, 1280)

In [144]:
from skimage.color import rgb2gray


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-144-5157c25d77a9> in <module>()
----> 1 camera.convert(L)

AttributeError: 'numpy.ndarray' object has no attribute 'convert'

In [ ]: