Пример #1
0
 def test_load_dictionary(self):
     d = du.load_dictionary('SUN908_inoutdoor_dictionary')
     self.assertTrue(d['/a/art_studio']['indoor'])
     # test for categories that are not marked as indoor or outdoor
     self.assertFalse(any(d['/a/archaelogical_excavation'].values()))
     # test for categories that are marked as both indoor and outdoor
     self.assertFalse(in_xor_out_door(d['/t/ticket_booth']))
     # test for categories that are marked as both outdoor natural and outdoor man-made
     self.assertFalse(natural_xor_man_made(d['/a/aqueduct']))
Пример #2
0
    for category in categories:
        try:
            h5_handle.root._f_get_child(category)
        except tables.NoSuchNodeError:
            continue
        catGroup = h5_handle.root._f_get_child(category)
        for node in catGroup._v_children.iterkeys():
            file_list.append(catGroup._v_pathname + "/" + node)
    return file_list


if __name__ == "__main__":
    # load the dictionary that associates each category with an "indoor" vs "outdoor" specification
    # but filter it so it only includes categories that are not double-marked as both indoor and outdoor
    # and return the lists of the indoor vs the outdoor categories
    (indoor_list, outdoor_list) = get_doorness_lists(du.load_dictionary("SUN908_inoutdoor_dictionary"))
    # get the list of images for each "doorness" condition.

    # load the HDF5 file that was created using the pytables library
    # TODO put this back?
    with tables.open_file("/clusterfs/cortex/scratch/shiry/places32.h5", "r") as h:
        # every array corresponding to one image can be accessed like so:
        # h.root.a.abbey.<IMAGE NAME>[:]

        seed(1)
        # t = time.time()
        file_list = file_list_for_categories(outdoor_list, h)

        # print(time.time() - t)
        shuffle(file_list)