论文:U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection - 2020
作者:Xuebin Qin, Zichen Zhang, Chenyang Huang, Masood Dehghan, Osmar R.Zaiane, MartinJagersand
团队:University of Alberta, Edmonton, Canada
Github - U-2-Net
U2NET其实就是将一个unet作为基本单元,将这些基本单元以unet形式组合。
其中每一个小的单元
具体的原理其实网络上很多了,如http://aiuai.cn/aifarm1396.html
这里我用这个网络模拟一下人物肖像,这里主要是手绘风格,如下图:
其实说白了也是一种分割结果,无非就是一些特征分割出来,最终看起来像是人物肖像。按照这个思路其实u2net就很适合做这件事了。
首先,准备数据集,这里主要用的就是APDrawingDB中使用的数据集,每一个数据对就是一张图片,一半是原图一般是肖像图,然后我们根据这个来更改dataloader的内容。
def __getitem__(self,idx):
image_full = cv2.imread(self.image_name_list[idx])
h,w,c = image_full.shape
image = image_full[0:h,0:w//2,:]
imname = self.image_name_list[idx]
imidx = np.array([idx])
if(0==len(self.label_name_list)):
label_3 = np.zeros(image.shape)
else:
label_3 = image_full[0:h,w//2:w,:]
这样就可以正常加载数据了,只是尝试的话其实别的参数也不用过于调整,直接python u2net_train.py就可以了,唯一需要注意的就是及其占显存。
这里我训练了50个epoch,最终结果如下:
看起来还可以哦~
不过这个网络参数是真的多,如果要想提升结果。。。。还是得好机器啊,哎。。。