MODNet icon indicating copy to clipboard operation
MODNet copied to clipboard

Full scripts for training

Open lrjj opened this issue 3 years ago • 4 comments

Hello,could u please provide a few samples of your training data and the full scripts for training? Thanks

lrjj avatar Apr 22 '21 06:04 lrjj

Hi, thanks for your attention. Releasing of our full scripts for training is scheduled after this paper is accepted.

ZHKKKe avatar Apr 24 '21 19:04 ZHKKKe

I read the training code. Method supervised_training_iter takes image, trimap and gt_matte.

To generate trimap I wrote next code:

def makeEdgeMask(mask, width):
    kernel = np.ones((width,width), np.uint8)

    erosion = cv2.erode(mask, kernel, iterations = 1)
    dilation = cv2.dilate(mask, kernel, iterations = 1)

    return dilation - erosion

def makeTrimap(mask, width = 5):
   edgeMask = makeEdgeMask(mask, width)
   trimap = mask.astype(np.float)
   trimap[edgeMask == 1] = 0.5
   return trimap

@lrjj, may be that will help you.

In my case code training technically works - semantic, detail and matte losses become very low:

2021-05-06_22-36-50

But generated masks are incorrect.

As training data I took 640x480 CocoDataset images.

kapulkin avatar May 06 '21 19:05 kapulkin

I read the training code. Method supervised_training_iter takes image, trimap and gt_matte.

To generate trimap I wrote next code:

def makeEdgeMask(mask, width):
    kernel = np.ones((width,width), np.uint8)

    erosion = cv2.erode(mask, kernel, iterations = 1)
    dilation = cv2.dilate(mask, kernel, iterations = 1)

    return dilation - erosion

def makeTrimap(mask, width = 5):
   edgeMask = makeEdgeMask(mask, width)
   trimap = mask.astype(np.float)
   trimap[edgeMask == 1] = 0.5
   return trimap

@lrjj, may be that will help you.

In my case code training technically works - semantic, detail and matte losses become very low:

2021-05-06_22-36-50

But generated masks are incorrect.

As training data I took 640x480 CocoDataset images.

Hello, if it is convenient, could you please send me a copy of your training script?Thank you very much.

vkl-git avatar Jun 28 '21 07:06 vkl-git

哈喽 我实现了一个完整的训练代码 用的是bg的数据 效果不好 欢迎一起探讨一下

Fight-hawk avatar Sep 13 '21 02:09 Fight-hawk