def get_seg_image(zipfile, cat_id, example_id): topic = os.path.join('expert_verified', 'seg_img') subpath = _get_subpath(cat_id, example_id, topic, 'png') return load_image_from_zip(zipfile, subpath)
def get_fixed_meshes_dir(): return os.path.join(blender_renderings_dir, '_fixed_meshes') def get_fixed_meshes_zip_path(cat_id): return os.path.join(get_fixed_meshes_dir(), '%s.zip' % cat_id) if __name__ == '__main__': from shapenet.core import cat_desc_to_id, get_example_ids from shapenet.image import load_image_from_zip, with_background import random import zipfile import matplotlib.pyplot as plt from config import RenderConfig cat_desc = 'plane' cat_id = cat_desc_to_id(cat_desc) example_ids = get_example_ids(cat_id) random.shuffle(example_ids) config = RenderConfig() with zipfile.ZipFile(config.get_zip_path(cat_id), 'r') as zf: for example_id in example_ids: subpath = get_example_image_subpath(cat_id, example_id, config.view_angle(5)) image = load_image_from_zip(zf, subpath) image = with_background(image, 255) plt.imshow(image) plt.show()
def __getitem__(self, key): topic = os.path.join('expert_verified', 'seg_img') subpath = _get_subpath(self._cat_id, key, topic, 'png') return load_image_from_zip(self._file, subpath)
def get_seg_image(zip_file, cat_id, example_id): with zip_file.open(_subpath('points_label', cat_id, example_id, 'png')) as fp: image = load_image_from_zip(fp) return image