Module vipy.data.caltech101
Expand source code Browse git
import os
from vipy.util import remkdir
import vipy.downloader
import vipy.dataset
from vipy.image import ImageCategory
URL = 'https://data.caltech.edu/records/mzrjq-6wc02/files/caltech-101.zip'
SHA1 = 'd1cc0e3686b03d5e1a7e9b734c6d04f60857d674'
class Caltech101(vipy.dataset.Dataset):
"""Caltech-101 dataset: https://data.caltech.edu/records/mzrjq-6wc02"""
def __init__(self, datadir):
"""Caltech101, provide a datadir='/path/to/store/caltech101' """
# Download
self._datadir = remkdir(datadir)
if not os.path.exists(os.path.join(self._datadir, 'caltech-101/101_ObjectCategories.tar.gz')):
vipy.downloader.download_and_unpack(URL, self._datadir, sha1=SHA1)
if not os.path.exists(os.path.join(self._datadir, 'caltech-101/101_ObjectCategories/')):
vipy.downloader.unpack(os.path.join(self._datadir, 'caltech-101/101_ObjectCategories.tar.gz'), os.path.join(self._datadir, 'caltech-101'))
# Create dataset
imlist = []
categorydir = os.path.join(self._datadir, 'caltech-101', '101_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-101')
Classes
class Caltech101 (datadir)
-
Caltech-101 dataset: https://data.caltech.edu/records/mzrjq-6wc02
Caltech101, provide a datadir='/path/to/store/caltech101'
Expand source code Browse git
class Caltech101(vipy.dataset.Dataset): """Caltech-101 dataset: https://data.caltech.edu/records/mzrjq-6wc02""" def __init__(self, datadir): """Caltech101, provide a datadir='/path/to/store/caltech101' """ # Download self._datadir = remkdir(datadir) if not os.path.exists(os.path.join(self._datadir, 'caltech-101/101_ObjectCategories.tar.gz')): vipy.downloader.download_and_unpack(URL, self._datadir, sha1=SHA1) if not os.path.exists(os.path.join(self._datadir, 'caltech-101/101_ObjectCategories/')): vipy.downloader.unpack(os.path.join(self._datadir, 'caltech-101/101_ObjectCategories.tar.gz'), os.path.join(self._datadir, 'caltech-101')) # Create dataset imlist = [] categorydir = os.path.join(self._datadir, 'caltech-101', '101_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-101')
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