Ejemplo n.º 1
0
        def make_workspace(self, classes):
            module = C.ClassifyPixels()
            module.module_num = 1
            module.image_name.value = INPUT_IMAGE_NAME
            path, filename = os.path.split(self.classifier_file)
            module.h5_directory.dir_choice = C.ABSOLUTE_FOLDER_NAME
            module.h5_directory.custom_path = path
            module.classifier_file_name.value = filename
            module.probability_maps[
                0].output_image.value = get_output_image_name(0)
            module.probability_maps[0].class_sel.value = classes[0]
            for i, class_sel in enumerate(classes):
                module.add_probability_map()
                module.probability_maps[
                    i + 1].output_image.value = get_output_image_name(i + 1)
                module.probability_maps[i + 1].class_sel.value = class_sel
            pipeline = cpp.Pipeline()

            def callback(caller, event):
                self.assertFalse(isinstance(event, cpp.RunExceptionEvent))

            pipeline.add_listener(callback)
            pipeline.add_module(module)
            image_set_list = cpi.ImageSetList()
            image_set = image_set_list.get_image_set(0)
            r = np.random.RandomState()
            r.seed(0)
            pixels = r.uniform(size=(64, 72))
            image_set.add(INPUT_IMAGE_NAME, cpi.Image(pixels, scale=255))
            workspace = cpw.Workspace(pipeline, module, image_set,
                                      cpo.ObjectSet(), cpmeas.Measurements(),
                                      image_set_list)
            return workspace, module
Ejemplo n.º 2
0
 def test_03_01_prepare_to_create_batch(self):
     module = C.ClassifyPixels()
     module.h5_directory.dir_choice = C.ABSOLUTE_FOLDER_NAME
     module.h5_directory.custom_path = "/foo"
     def fn_alter_path(path, *args, **kwargs):
         self.assertEqual(path, "/foo")
         return "/bar"
     module.prepare_to_create_batch(None, fn_alter_path)
     self.assertEqual(module.h5_directory.custom_path, "/bar")