- read the CUB data files into python data structures
- expose simple data access api methods
- add original image photos sizes data
- expose csv writer method to write the images attributes into single csv file
download the CUB data files from here
- os
- csv
- PIL
- CUB_PATH # (class init) path to the downloaded CUB databse folder
- CSV_PATH # (csv write method) csv filename path to write
- getCubSize() # CUB database size (int images list size, int number of categories)
- getImages() # CUB images list (dictionary 'image number' : 'image path')
- getImagesSizes() # CUB images sizes (dictionary 'image number' : ['width','height'])
- getBoxes() # CUB bounding boxes (dictionary 'image number' : ['xcenter','ycenter', 'width', 'height])
- getImgClasses() # CUB images classes (dictionary 'image number' : 'class number')
- getClasses() # CUB classes names (dictionary 'class number' : 'class name')
- writeCubToCsv(file path) # write the CUB data to csv file and return the data as pandas dataframe,
- file format :
- csv header row,
- data rows :
- image path,
- image size,
- image class name,
- bounding box xmin,
- bounding box ymin,
- bounding box xmax,
- bounding box ymax,
- bounding box centerx,
- bounding box centery,
- bounding box width,
- bounding box height,
- file format :
# {put your input in these brackets}
cub = CUB_ReadWrite({cub download folder path}) # inialize class read all CU data files from 'folder path'
cubDf = cub.writeCubToCsv({output csv file name path}) # writes csv file to 'file path' in format decribed above
del(cub) # deletes cub object
#{put your input in these brackets}
cub = CUB_ReadWrite({cub download folder path}) # inialize class read all CU data files from 'folder path'
cub.{method()} # call class methods, retuns CUB data as described above
cubDf = cub.writeCubToCsv({output csv file name path}) # writes csv file to 'file path' in format decribed above
del(cub) # deletes cub object
#{put your input in these brackets}
cub = CUB_ReadWrite({cub download folder path}) # inialize class read all CU data files from 'folder path'
cubDf = cub.writeCubToCsv({output csv file name path}) # writes csv file to 'file path' in format decribed above
del(cub) # deletes cub object
# ... use pandas methods and queries on the cubDf dataframe
#csvData = pd.read_csv(csvPath) # you can read the csv file into pandas dataframe
# see the notebook for pandas queries example
open this notebook to see a demo of this class usage
(if you can't see the notebook, this is due to github ipynb render issues, please download and use locally, make sure you have the prerequesites installed)