Skip to content

Instantly share code, notes, and snippets.

@rosenfeldamir
Last active October 13, 2017 19:52
Show Gist options
  • Save rosenfeldamir/107e624647ab77bd91d1d5fa4d560d39 to your computer and use it in GitHub Desktop.
Save rosenfeldamir/107e624647ab77bd91d1d5fa4d560d39 to your computer and use it in GitHub Desktop.
# Let's map between the fine and coarse categories.
cifar100Dir = '/data/cifar-100-python/' # modify this to your own directory...
import cPickle as pickle
import os
meta = pickle.load(open(os.path.join(cifar100Dir,'meta')))
test = pickle.load(open(os.path.join(cifar100Dir,'test')))
test_fine_labels = test['fine_labels']
test_coarse_labels = test['coarse_labels']
fine_to_coarse = dict(set((zip(test_fine_labels,test_coarse_labels))))
fine_label_names = meta['fine_label_names']
coarse_label_names = meta['coarse_label_names']
coarse_to_fine = {}
for k,v in fine_to_coarse.iteritems():
#print fine_label_names[k],'-->',coarse_label_names[v]
if v not in coarse_to_fine:
coarse_to_fine[v] = [k]
else:
coarse_to_fine[v].append(k)
print 'coarse-->fine mapping'
print '---------------------'
for i,j in coarse_to_fine.iteritems():
print coarse_label_names[i],':',
for k in j:
print fine_label_names[k],',',
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment