Module vipy.data.caltech256
Expand source code Browse git
import os
import vipy.downloader
import vipy.dataset
from vipy.util import remkdir
from vipy.image import ImageCategory
URL = 'https://data.caltech.edu/records/nyy15-4j048/files/256_ObjectCategories.tar'
SHA1 = None
class Caltech256(vipy.dataset.Dataset):
"""Caltech-256 dataset: https://data.caltech.edu/records/nyy15-4j048"""
def __init__(self, datadir):
# Download (if not cached)
self._datadir = remkdir(datadir)
if not os.path.exists(os.path.join(self._datadir, '256_ObjectCategories')):
vipy.downloader.download_and_unpack(URL, self._datadir, sha1=SHA1)
# Create dataset
imlist = []
categorydir = os.path.join(self._datadir, '256_ObjectCategories')
for (idx_category, category) in enumerate(os.listdir(categorydir)):
imdir = os.path.join(categorydir, category)
for im in os.listdir(imdir):
imlist.append(ImageCategory(filename=os.path.join(categorydir, category, im), category=category))
super().__init__(imlist, id='caltech-256')
Classes
class Caltech256 (datadir)
-
Caltech-256 dataset: https://data.caltech.edu/records/nyy15-4j048
Expand source code Browse git
class Caltech256(vipy.dataset.Dataset): """Caltech-256 dataset: https://data.caltech.edu/records/nyy15-4j048""" def __init__(self, datadir): # Download (if not cached) self._datadir = remkdir(datadir) if not os.path.exists(os.path.join(self._datadir, '256_ObjectCategories')): vipy.downloader.download_and_unpack(URL, self._datadir, sha1=SHA1) # Create dataset imlist = [] categorydir = os.path.join(self._datadir, '256_ObjectCategories') for (idx_category, category) in enumerate(os.listdir(categorydir)): imdir = os.path.join(categorydir, category) for im in os.listdir(imdir): imlist.append(ImageCategory(filename=os.path.join(categorydir, category, im), category=category)) super().__init__(imlist, id='caltech-256')
Ancestors
Inherited members
Dataset
:archive
categories
chunk
class_to_index
classes
classlist
clone
count
countby
density
duration_in_seconds
filter
flatten
id
index_to_class
inverse_frequency_weight
istype
jsondir
label_to_index
list
load
map
merge
minibatch
multilabel_inverse_frequency_weight
num_categories
num_classes
num_labels
percentage
replace
save
set
shuffle
shuffler
sort
split
split_by_videoid
synonym
take
take_per_category
takefilter
takelist
takeone
to_torch
to_torch_tensordir
tohtml
tojsondir
tolist
video_duration_in_seconds
video_montage
zip