Created
January 18, 2019 23:45
-
-
Save dichotomies/7b4f1579d9f638932dab4701585db1ca to your computer and use it in GitHub Desktop.
cars parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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