Exemple #1
0
    def prepare_data(self, images, labels=None):
        if (labels is None):
            for (i, image) in enumerate(images):
                number = ("%0.3d" % (i+1))
                path_save = path.join(self.dn_test_out, mkdir=True)

                image, _ = dip.preprocessor(image, None)
                original_name = (const.fn_PREPROCESSING % (number))
                data.imwrite(path.join(path_save, original_name), image)

                yield self.arch.prepare_input(image)
        else:
            for (image, label) in zip(images, labels):
                (image, label) = dip.preprocessor(image, label)
                yield self.arch.prepare_input(image), self.arch.prepare_input(label)
Exemple #2
0
def tolabel():
    dn_tolabel = path.out(const.dn_TOLABEL, mkdir=False)

    if path.exist(dn_tolabel):
        
        dir_save = path.out(const.dn_TOLABEL)
        images = data.fetch_from_path(dir_save)

        for (i, image) in enumerate(images):
            path_save = path.join(dir_save, "label", mkdir=True)
            file_name = ("%0.3d.png" % (i+1))
            file_save = path.join(path_save, file_name)

            img_pp, _ = dip.preprocessor(image, None)
            data.imwrite(file_save, img_pp)
    else:
    	print("\n>> Folder not found (%s)\n" % dn_tolabel)
Exemple #3
0
    def save_predict(self, original, image):
        path_save = path.join(self.dn_test_out, mkdir=True)

        with open(path.join(path_save, (const.fn_SEGMENTATION)), 'w+') as f:
            for (i, image) in enumerate(image):
                number = ("%0.3d" % (i+1))
                image_name = (const.fn_PREDICT % (number))

                image = dip.posprocessor(original[i], self.arch.prepare_output(image))
                data.imwrite(path.join(path_save, image_name), image)

                seg = (image == 255).sum()
                f.write(("Image %s was approximately %f segmented (%s pixels)\n" % (number, (seg/image.size), seg)))

                original_name = (const.fn_ORIGINAL % (number))
                data.imwrite(path.join(path_save, original_name), original[i])

                overlay_name = (const.fn_OVERLAY % (number))
                overlay = dip.overlay(original[i], image)
                data.imwrite(path.join(path_save, overlay_name), overlay)
        f.close()