Beispiel #1
0
def switch_mapping(segmap, source_map, destination_map):
    # This assumes label names in different mappings are the same.
    # This function is mainly useful to map from the old class mapping to the now default NYU mapping.
    source_label_map = LabelIdMapping.from_csv(source_map)
    destination_label_map = LabelIdMapping.from_csv(destination_map)

    new_segmap = np.zeros_like(segmap)
    unq = np.unique(segmap)

    for id in unq:
        label_name = source_label_map.label_from_id(id)
        if destination_label_map.has_label(label_name):
            destination_id = destination_label_map.id_from_label(
                source_label_map.label_from_id(id))
            new_segmap[segmap == id] = destination_id

    return new_segmap
    def run(self):
        label_mapping = LabelIdMapping.from_csv(
            Utility.resolve_path(
                os.path.join('resources', 'id_mappings', 'nyu_idset.csv')))
        # Add label mapping to global storage, s.t. it could be used for naming semantic segmentations.
        GlobalStorage.set("label_mapping", label_mapping)

        loaded_objects = SuncgLoader.load(self.house_path, label_mapping,
                                          self.suncg_dir)
        self._set_properties(loaded_objects)
Beispiel #3
0
    def run(self):
        label_mapping = LabelIdMapping.from_csv(self.mapping_file)
        # Add label mapping to global storage, s.t. it could be used for naming semantic segmentations.
        GlobalStorage.set("label_mapping", label_mapping)

        loaded_objects = Front3DLoader.load(
            json_path=self.config.get_string("json_path"),
            future_model_path=self.config.get_string("3D_future_model_path"),
            front_3D_texture_path=self.config.get_string(
                "3D_front_texture_path"),
            label_mapping=label_mapping,
            ceiling_light_strength=self.config.get_float(
                "ceiling_light_strength", 0.8),
            lamp_light_strength=self.config.get_float("lamp_light_strength",
                                                      7.0))
        self._set_properties(loaded_objects)
Beispiel #4
0
    def run(self):
        """
        Run the module, loads all the objects and set the properties correctly (including the category_id)
        """
        label_mapping = LabelIdMapping.from_csv(
            Utility.resolve_path(
                os.path.join('resources', 'id_mappings', 'nyu_idset.csv')))
        # Add label mapping to global storage, s.t. it could be used for naming semantic segmentations.
        GlobalStorage.set("label_mapping", label_mapping)
        # load the objects (Use use_image_search=False as some image names have a "/" prefix which will lead to blender search the whole root directory recursively!
        loaded_objects = SceneNetLoader.load(
            file_path=self._file_path,
            texture_folder=self._texture_folder,
            label_mapping=label_mapping,
            unknown_texture_folder=self._unknown_texture_folder)

        # add custom properties
        self._set_properties(loaded_objects)
Beispiel #5
0
import os

parser = argparse.ArgumentParser()
parser.add_argument(
    'house', help="Path to the house.json file of the SUNCG scene to load")
parser.add_argument('output_dir',
                    nargs='?',
                    default="examples/datasets/suncg_with_cam_sampling/output",
                    help="Path to where the final files, will be saved")
args = parser.parse_args()

Initializer.init()

# load the objects into the scene
label_mapping = LabelIdMapping.from_csv(
    Utility.resolve_path(
        os.path.join('resources', 'id_mappings', 'nyu_idset.csv')))
objs = SuncgLoader.load(args.house, label_mapping)

# makes Suncg objects emit light
SuncgLighting.light()

# Init sampler for sampling locations inside the loaded suncg house
point_sampler = SuncgPointInRoomSampler(objs)
# Init bvh tree containing all mesh objects
bvh_tree = MeshObject.create_bvh_tree_multi_objects(
    [o for o in objs if isinstance(o, MeshObject)])

poses = 0
tries = 0
while tries < 10000 and poses < 5:
Beispiel #6
0
parser.add_argument("front", help="Path to the 3D front file")
parser.add_argument("future_folder",
                    help="Path to the 3D Future Model folder.")
parser.add_argument("front_3D_texture_path",
                    help="Path to the 3D FRONT texture folder.")
parser.add_argument("output_dir",
                    help="Path to where the data should be saved")
args = parser.parse_args()

if not os.path.exists(args.front) or not os.path.exists(args.future_folder):
    raise Exception("One of the two folders does not exist!")

Initializer.init()
mapping_file = Utility.resolve_path(
    os.path.join("resources", "front_3D", "3D_front_mapping.csv"))
mapping = LabelIdMapping.from_csv(mapping_file)

# set the light bounces
RendererUtility.set_light_bounces(diffuse_bounces=200,
                                  glossy_bounces=200,
                                  ao_bounces_render=200,
                                  max_bounces=200,
                                  transmission_bounces=200,
                                  transparent_max_bounces=200,
                                  volume_bounces=0)

# load the front 3D objects
loaded_objects = Front3DLoader.load(
    json_path=args.front,
    future_model_path=args.future_folder,
    front_3D_texture_path=args.front_3D_texture_path,