Skip to content

Instantly share code, notes, and snippets.

@dichotomies
Created January 18, 2019 23:45
Show Gist options
  • Save dichotomies/7b4f1579d9f638932dab4701585db1ca to your computer and use it in GitHub Desktop.
Save dichotomies/7b4f1579d9f638932dab4701585db1ca to your computer and use it in GitHub Desktop.
cars parsing
from .base import *
import scipy.io
class Cars(BaseDataset):
def __init__(self, root, classes, transform = None):
BaseDataset.__init__(self, root, classes, transform)
annos_fn = 'cars_annos.mat'
cars = scipy.io.loadmat(os.path.join(root, annos_fn))
ys = [int(a[5][0] - 1) for a in cars['annotations'][0]]
im_paths = [a[0][0] for a in cars['annotations'][0]]
index = 0
for im_path, y in zip(im_paths, ys):
if y in classes: # choose only specified classes
self.im_paths.append(os.path.join(root, im_path))
self.ys.append(y)
self.I += [index]
index += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment