Esempio n. 1
0
class EvalPuppet(Callback):
    def __init__(self, generator, height=48, width=48, batch_size=1):
        super(EvalPuppet, self).__init__()
        self.batch_size = batch_size
        self.generator = generator
        self.postprocess = PostProcess(height, width)
        self.evaluate = Eval()

    def on_epoch_end(self, epoch, logs=None):
        # generate data
        image_group, guide_mask_group, annkp_group = self.generator.next()
        predict_mask_group = self.model.predict_on_batch(image_group)[-1]
        outobjects_group = []
        for x in range(self.batch_size):
            # select last level see, and unuse other level
            mask = predict_mask_group[x, :, :, :]
            outobjects_group.append(self.postprocess.process(mask))
        self.evaluate.evaluate(annkp_group, outobjects_group)
Esempio n. 2
0
def main():
    # build dataset
    batch_size = 1
    height = 48
    width = 48
    dataset = TestDataGenerator(PuppetDataset, 4, batch_size, height=height, width=width)
    evaluate = Eval()
    postprocess = PostProcess(48, 48)
    # generate and display
    image_group, guide_mask_group, annkp_group = dataset.next()
    outobjects_group = []
    for x in range(batch_size):
        image = image_group[x]
        # select last level see, and unuse other level
        mask = guide_mask_group[x][-1]
        display_my_masks(image, mask)
        # use groudtruth mask directly as predict mask to process
        outobjects_group.append(postprocess.process(mask))
    evaluate.evaluate(annkp_group, outobjects_group)