Beispiel #1
0
    def rm_txt_all(self): 
        ''' 
        Remove text of all image.
        NOTE: If image has previously saved masks, then use it.
        '''
        if state.now_image() is None: return None

        self.saveMask.emit(state.now_mask()) # save current edited mask
        no_mask_path_pairs = fp.lremove(
            lambda pair: Path(pair.mask).exists(),
            state.img_mask_pairs()
        )
        new_masks = fp.map(
            lambda p: imgpath2mask(p.img),
            no_mask_path_pairs
        )
        for mask,pair in tqdm(zip(new_masks, no_mask_path_pairs),
                              total=len(no_mask_path_pairs),
                              desc='Generate Masks'):
            io.save(pair.mask, mask)

        img_paths,mask_paths = state.project()
        images= fp.map(lambda p: io.load(p, io.IMAGE), img_paths)
        masks = fp.map(lambda p: io.load(p, io.MASK), mask_paths)
        inpainteds = fp.map(core.inpainted, images,masks)

        for ipath,inpainted in tqdm(zip(img_paths, inpainteds),
                                    total=len(img_paths),
                                    desc='  Remove Texts'):
            io.save(ipath, inpainted) 
        self.update_gui()
Beispiel #2
0
    def gen_mask(self): 
        imgpath = state.now_image()
        if imgpath is None: return None

        mask = imgpath2mask(imgpath)
        io.save(state.now_mask(), mask)
        self.update_gui()

        return mask
Beispiel #3
0
    def gen_mask_all(self):
        imgpath = state.now_image()
        if imgpath is None: return None

        mask = fp.go(imgpath, lambda path: io.load(path, io.NDARR),
                     core.segmap, io.segmap2mask)
        io.save(state.now_mask(), mask)
        self.update_gui()

        return mask
Beispiel #4
0
    def rm_txt(self):
        imgpath  = state.now_image()
        maskpath = state.now_mask()
        if imgpath is None: return None

        self.saveMask.emit(maskpath) # save edited mask
        image = io.load(imgpath, io.IMAGE)
        mask  =(io.load(maskpath, io.MASK) 
                if Path(maskpath).exists()
                else io.mask2segmap(self.gen_mask()))
        inpainted = core.inpainted(image, mask)

        io.save(state.now_image(), inpainted) 
        self.update_gui()
Beispiel #5
0
 def update_gui(self):
     now_imgpath = state.now_image()
     if now_imgpath:
         self.updateImage.emit(now_imgpath)
         self.provideMask.emit(state.now_mask())
         self.im_model.update()
Beispiel #6
0
 def display(self, index):
     self.saveMask.emit(state.now_mask())
     state.cursor(index)
     self.update_gui()
Beispiel #7
0
 def display_prev(self):
     import time 
     self.saveMask.emit(state.now_mask())
     state.prev()
     self.update_gui()