def gen_layout(self, bbox_sampled, label_original, opt):
        # crop canvas
        input_dict = crop_canvas(bbox_sampled, label_original, opt)

        # generate layout
        label_generated = self.G_box2mask.evaluate(
            {
                'label_map':
                Variable(input_dict['label'], volatile=True),
                'mask_ctx_in':
                Variable(input_dict['mask_ctx_in'], volatile=True),
                'mask_out':
                Variable(input_dict['mask_out'], volatile=True),
                'mask_in':
                Variable(input_dict['mask_in'], volatile=True),
                'cls':
                Variable(input_dict['cls'], volatile=True),
                'label_map_orig':
                Variable(input_dict['label_orig'], volatile=True),
                'mask_ctx_in_orig':
                Variable(input_dict['mask_ctx_in_orig'], volatile=True),
                'mask_out_orig':
                Variable(input_dict['mask_out_orig'], volatile=True)
            },
            target_size=(input_dict['label_orig'].size()[2:4]))

        # paste canvas
        label_canvas = paste_canvas(label_original, label_generated.data, \
            input_dict, resize=False)

        return label_canvas, input_dict, label_generated.data
    def gen_image(self, bbox_sampled, img_original, label_generated, opt):
        # crop canvas
        input_dict = crop_canvas(bbox_sampled, label_generated, opt, \
            img_original=img_original, transform_img=True)

        # generate layout
        img_generated = self.G_mask2img.inference(
            Variable(input_dict['label'], volatile=True),
            Variable(torch.zeros_like(input_dict['label']), volatile=True),
            Variable(input_dict['image'], volatile=True),
            Variable(input_dict['mask_in'], volatile=True),
            Variable(input_dict['mask_out'], volatile=True))
        # paste canvas
        img_canvas = paste_canvas(img_original, (img_generated.data+1)/2, \
            input_dict, method=Image.BICUBIC, is_img=True)

        return img_canvas, input_dict, img_generated.data