├── MP4_processor.py ├── README.md ├── cartoon.py ├── dataset2 ├── annotations │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.png │ ├── 14.png │ ├── 15.png │ ├── 16.png │ ├── 17.png │ ├── 18.png │ ├── 19.png │ ├── 2.png │ ├── 20.png │ ├── 21.png │ ├── 22.png │ ├── 23.png │ ├── 24.png │ ├── 25.png │ ├── 26.png │ ├── 27.png │ ├── 28.png │ ├── 29.png │ ├── 3.png │ ├── 30.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png ├── test_anno │ ├── 1.png │ ├── 10.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png ├── test_images │ ├── 1.png │ ├── 10.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png ├── train_anno │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.png │ ├── 14.png │ ├── 15.png │ ├── 16.png │ ├── 17.png │ ├── 18.png │ ├── 19.png │ ├── 2.png │ ├── 20.png │ ├── 21.png │ ├── 22.png │ ├── 23.png │ ├── 24.png │ ├── 25.png │ ├── 26.png │ ├── 27.png │ ├── 28.png │ ├── 29.png │ ├── 3.png │ ├── 30.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png └── train_images │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.png │ ├── 14.png │ ├── 15.png │ ├── 16.png │ ├── 17.png │ ├── 18.png │ ├── 19.png │ ├── 2.png │ ├── 20.png │ ├── 21.png │ ├── 22.png │ ├── 23.png │ ├── 24.png │ ├── 25.png │ ├── 26.png │ ├── 27.png │ ├── 28.png │ ├── 29.png │ ├── 3.png │ ├── 30.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png ├── predict.py └── show.py /MP4_processor.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import os 3 | import imageio 4 | import keras_segmentation 5 | 6 | def output_segmentations(model,inp=None,outp=None): 7 | assert inp and outp,"None type inp and outp is not allowed" 8 | names = os.listdir(inp) 9 | for name in names: 10 | model.predict_segmentation(inp=os.path.join(inp,name),out_fname=os.path.join(outp,name)) 11 | img = cv2.imread(os.path.join(outp,name)) 12 | img_origin = cv2.imread(os.path.join(inp,name)) 13 | h, w, c = img.shape 14 | for i in range(h): 15 | for j in range(w): 16 | if img[i, j, 0] == 197: 17 | img_origin[i, j] = 255 18 | cv2.imwrite(os.path.join(outp,"seg/seg_"+name),img_origin) 19 | 20 | def mp4Processor(file_path,model): 21 | mp4 = cv2.VideoCapture(file_path) 22 | assert mp4.isOpened(), "Failed to open mp4 file" 23 | rval,frame = mp4.read() 24 | i = 1 25 | # 分解视频图片 26 | while rval: 27 | cv2.imwrite("mp4_images/" + str(i) + ".png",frame) 28 | i += 1 29 | rval,frame = mp4.read() 30 | 31 | # 抠图 32 | output_segmentations(model,"mp4_images/","gif_images/") 33 | 34 | seg_names = os.listdir("gif_images/seg/") 35 | frames = [imageio.imread(os.path.join("gif_images/seg",name)) for name in seg_names] 36 | imageio.mimsave("output.gif",frames,'GIF',duration=0.05) 37 | 38 | if __name__ == "__main__": 39 | model = keras_segmentation.predict.model_from_checkpoint_path("tmp/pspnet_transfer") 40 | mp4Processor("1.mp4",model) 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 基于迁移学习的动漫角色语义分割 2 | 3 | # 1.前言 4 | 基于语义分割的场景分析是计算机视觉中的一个基本问题,其目的是为图像中的==每个像素指定一个类别标签==。 5 | 6 | 近年来,以FCN的提出为转折点,语义分割得到了快速的发展,随后==PSPnet(金字塔场景解析网络)==也被提出,较好地结局了FCN中存在的语境关系不匹配的问题。 7 | 8 | 数据集方面,大量优质的数据集不断涌现,典型的有MS COCO、Pascal Voc 2012、ADE20K_MIT等等,这些数据集不仅为我们提供了大量优质的训练样本,同时也有许多杰出的前辈为我们提供了各种网络在这些数据集的预训练模型。 9 | 10 | 迁移学习的思想也给了我们很大的启发。在数据极端匮乏的情况下,one-shot、zero-shot等思想大有用武之地。 11 | 12 | 迁移学习的方法使我们避免了为大量数据进行人工标记,相反,我们只需要对少量的样本进行标记,再基于一些预训练模型进行二次训练,就可以得到与在大量数据下训练的结果。 13 | 14 | # 2.构造数据集 15 | 16 | ### (0).数据集格式 17 | 这一点必须首先说明。我们知道,语义分割的输入是一张图片,输出也是一张图片,但事实上==输入输出的维度可能并不完全一致==,输入往往是一张彩色的图,包含rgb(红黄蓝)三个通道,可以看做一个==高×宽×通道数==的张量,而输出往往可能是一个==高×宽==的二维矩阵,其中每一个元素对应输入像素的类别。 18 | 19 | 因此考虑训练数据,每一行数据都应该有两张图片,一张是原图,可以理解成features,一张是带有类别标记的图片。 20 | 21 | keras_segmentation官方博客给出了一个数据集的示例。其结构如下 22 | ``` 23 | ─dataset1 24 | ├─annotations_prepped_test 25 | ├─annotations_prepped_train 26 | ├─images_prepped_test 27 | └─images_prepped_train 28 | ``` 29 | 30 | 该数据集大致分为两部分,训练集和测试集。训练集又分为==图片(images)集==和==注解(annotations)集==。下面我们重点关注一些这个注解集。 31 | 32 | 打开注解集发现,图片全都是黑的。 33 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190712235135883.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 34 | 事实上并非纯黑,当我们把亮度调高之后,就能看到大致的轮廓。 35 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/2019071223592089.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 36 | 37 | 官方对此的解释是,注解图片应当是一个与原图大小相同的图片。 38 | ```python 39 | import cv2 40 | import numpy as np 41 | 42 | ann_img = np.zeros((30,30,3)).astype('uint8') 43 | ann_img[ 3 , 4 ] = 1 # this would set the label of pixel 3,4 as 1 44 | ann_img[ 0 , 0 ] = 2 # this would set the label of pixel 0,0 as 2 45 | 46 | cv2.imwrite( "ann_1.png" ,ann_img ) 47 | ``` 48 | 上述是官方给出的一段制作annotation的代码,这里假设我们有一个30×30的图片,要为其创建注解,我们把[0,0]处的元素标记为了类别2,而[3,4]处标记为类别1。==类别0认为是背景(background)== 49 | 50 | 51 | 由于时间、人力等问题,我们人工构造大量动漫角色的数据集==并不现实==。因此我们制作一个小规模的数据集。 52 | 53 | 制备方法如下: 54 | 55 | ### (1).准备原始图片 56 | 我们可以轻易地从网络上搜集到许多包含动漫人物的图片。在该数据集中我们共收集==40张==,其中==30张作为训练集==,==10张作为测试集==。(如下图) 57 | ![训练数据](https://img-blog.csdnimg.cn/20190712230206542.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 58 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190712230231723.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 59 | ### (2).标记数据 60 | 此处我们使用数据标记工具==labelme==,这款工具可以让我们方便地在图上对关键区域进行标记。 61 | 62 | 标记数据时间很苦的事情,俗称人体描边。(以下为示例) 63 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190713001141465.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 64 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/2019071300115822.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 65 | 尽管描边非常辛苦,但是看着这些卡哇伊的角色,也就不觉得累了(题外话) 66 | 67 | 标记完成后,labelme会帮助我们保存==json文件==,这个json文件记录了我们的标记点的顺序和位置。 68 | 69 | ### (3).导出为mask型png 70 | labelme自带了命令 71 | ``` 72 | labelme_json_to_dataset <文件名>.json 73 | ``` 74 | 这条命令可以帮助我们把json转成带有mask的png图片,但==缺点是一条命令只能转换一个文件==,对于批量文件,可以用python写脚本处理(一下是一个示例)。 75 | ```python 76 | import os 77 | for i in range(1,n): 78 | os.system("labelme_json_to_dataset " + "test/" + str(i) + ".json") 79 | ``` 80 | 81 | 这样我们就得到了一个结果集。 82 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190713004050807.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 83 | 其中每个文件夹中包含了四个文件, ==.png文件==是我们需要的,我们把它设法提取到一个文件夹中。 84 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190713004154369.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 85 | 可以看到,这些png图片都是以黑色为背景,以rgb(128,0,0)为mask的图片。这离我们需要的注解格式还有最后一步距离。 86 | 87 | ### (4).注解化 88 | 最后一步,我们把上述png图片的所有红色mask区域的值都设置为1. 89 | 90 | 91 | 经过一顿猛如虎的操作,我们就得到了我们自创的数据集——动漫人物数据集,其结构同demo数据集一致,结构如下。 92 | ``` 93 | ─dataset2 94 | ├─test_anno 95 | ├─test_images 96 | ├─train_anno 97 | └─train_images 98 | ``` 99 | 100 | # 3.训练模型 101 | 这里我们采用比较先进的PSPnet。在keras_segmentation的框架下,训练这样一个网络并不是难事。 102 | 103 | ```python 104 | import keras_segmentation 105 | 106 | model = keras_segmentation.models.pspnet.pspnet_101(n_classes=2) 107 | 108 | 109 | model.train( 110 | train_images = "dataset2/train_images/", 111 | train_annotations = "dataset2/train_anno/", 112 | checkpoints_path="tmp/pspnet_1", 113 | epochs=5 114 | ) 115 | ``` 116 | 只需要指定好==所选的网络、训练的原图和注解文件==,并指定好==checkpoints的存放路径==,以及==训练的epochs==。 117 | 118 | 一方面,自己从底层搭建模型,可能会出错,这就会导致浪费大量的计算资源,另一方面,我水平也不够(根本原因),索性就直接用keras_segmentation提供的模型吧。 119 | 120 | 同样的,我们再基于预训练模型来train一个model,可以看做一种==迁移学习== 121 | ```python 122 | import keras_segmentation 123 | 124 | model = keras_segmentation.pretrained.pspnet_101_voc12() 125 | 126 | 127 | model.train( 128 | train_images = "dataset2/train_images/", 129 | train_annotations = "dataset2/train_anno/", 130 | checkpoints_path="tmp/pspnet_1", 131 | epochs=5 132 | ) 133 | ``` 134 | 135 | 这里要吐槽一下官方文档,官方文档在描述迁移学习的时候,提到了一种transfer_weights方法,但事实上包里面压根没这么个方法。 136 | 137 | 根据官方的设计,==训练似乎只能在linux机上进行==,虽然官方没有明说,但当我在Windows上运行训练的时候,报出来一个莫须有的错误,使得我非常恼火。大致是说注解文件夹下没有响应的文件。但事实上我用os.path.exist()方法检查返回结果是True。天无绝人之路,我们碰巧有一台linux机,就是上次想象出来的那台,刚好能够派上用场。 138 | 139 | 需要特别注意的是这个==checkpoints==,这里真是太坑爹了,害我白跑了两个晚上。在keras_segmentation中,模型并不通过model.save()方法进行保存,虽然可以这样保存,但是再次读取之后会出现一些莫名其妙的问题。事实上模型的参数都是保存在checkpoints中,加载时可以通过keras_segmentation.predict.model_from_checkpoints(checkpoints_path)进行加载。至于为什么如此设计,咱也不知道,咱也不敢问。 140 | 141 | # 4.模型评估 142 | 这里的准确率主要通过IoU(Intersection over Union)来反映,也就是预测结果与实际结果的交集。Keras_segmentation为我们提供了一个评估方法==keras_segmentation.predict.evaluate( model=None , inp_images=None , annotations=None , checkpoints_path=None )==。该方法接受一个模型、测试图片集和注解集,并输出测试集上的IoU。 143 | 144 | 但是当我们调用此方法的时候,竟然报了一行错误 145 | ``` 146 | Traceback (most recent call last): 147 | File "", line 1, in 148 | File "/home/gengshiqi/.local/lib/python3.6/site-packages/keras_segmentation/predict.py", line 111, in evaluate 149 | assert False , "not implemented " 150 | AssertionError: not implemented 151 | ``` 152 | 气急败坏的我打开这个包的evaluate方法一看,差点没背过气来 153 | ```python 154 | def evaluate( model=None , inp_inmges=None , annotations=None , checkpoints_path=None ): 155 | 156 | assert False , "not implemented " 157 | 158 | ious = [] 159 | for inp , ann in tqdm( zip( inp_images , annotations )): 160 | pr = predict(model , inp ) 161 | gt = get_segmentation_arr( ann , model.n_classes , model.output_width , model.output_height ) 162 | gt = gt.argmax(-1) 163 | iou = metrics.get_iou( gt , pr , model.n_classes ) 164 | ious.append( iou ) 165 | ious = np.array( ious ) 166 | print("Class wise IoU " , np.mean(ious , axis=0 )) 167 | print("Total IoU " , np.mean(ious )) 168 | ``` 169 | 方法的第一行竟然就是==assert False???==,还非常诚实地说道这个方法还没实现。我们把这行断言注释掉,还是运行不通。这肯定不是什么牛人写的包,但为了评估模型,evaluate又很难绕开,我只好免为其难把这个方法补全了,其实逻辑也不是很绕(以下是对该方法的修正) 170 | 171 | ```python 172 | def evaluate( model=None , inp_images=None , annotations=None , checkpoints_path=None ): 173 | 174 | names = os.listdir(inp_images) 175 | images_annotations = [(os.path.join(inp_images,name),os.path.join(annotations,name)) for name in names] 176 | 177 | ious = [] 178 | for inp , ann in images_annotations: 179 | pr = predict(model , inp ) 180 | gt = get_segmentation_arr( ann , model.n_classes , model.output_width , model.output_height ) 181 | gt = gt.argmax(-1) 182 | gt = gt.reshape(pr.shape) 183 | iou = metrics.get_iou( gt , pr , model.n_classes ) 184 | ious.append( iou ) 185 | ious = np.array( ious ) 186 | print("Class wise IoU " , np.mean(ious , axis=0 )) 187 | print("Total IoU " , np.mean(ious )) 188 | ``` 189 | 190 | 对此,我已经修复了该方法,并发布了升级版的python包。该包目前还不能在pip上安装,朋友们可以从我的GitHub上下载,然后通过 191 | ``` 192 | python setup.py install 193 | ``` 194 | 进行安装。GitHub地址为https://github.com/RadiumScriptTang/keras_segmentation 195 | 196 | 由于计算资源非常珍贵,我们没能尝试FCN等其他模型。我们不妨称呼psp在VOC2012数据集上的预训练模型叫做模型1,psp直接在动漫数据集上的训练模型称为模型2,预训练模型在动漫数据集的迁移学习模型称为模型3,实验结果如下 197 | 模型|模型1|模型2|模型3 198 | --|--|--|-- 199 | 背景IoU| 0.6729|0.6732|0.9083 200 | 动漫角色IoU|0| 0.6777|0.9112 201 | 平均IoU| 0.3365| 0.6754|0.9098 202 | 203 | 结果证明,迁移学习的成果还是相当明显的。 204 | 205 | # 5.模型分析 206 | 我们可以借助keras 提供的方法对模型进行可视化,这样可以清晰得看到网络结构。 207 | 208 | 在PSPnet中,作者引入了金字塔池化模块,如下图。 209 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190713193142481.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 210 | Hengshuang Zhao 等人分析了许多FCN网络结构的失败案例,他们观察到==语境关系不匹配==、==类别混淆==和==不明显的类别==等问题,并认为引入金字塔池化模块可以很好的结局这个问题。 211 | 212 | 在传统的psp网络中,金字塔池化层前的步骤基本也是普通的下采样操作。其结构如下。 213 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190713194043307.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 214 | 靠近底端的部分即为金字塔池化层。psp_101在上述基础上,在金字塔池化层前添加了许多交替的卷积层和batchNorm层。我推测大概有101层。 215 | 216 | 我们此处并不讨论why pspnet works(因为我也看不透)。 217 | 218 | # 6.效果展示 219 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190713174055423.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 220 | (上图为直接训练模型的结果) 221 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190713173826771.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1JhZGl1bVRhbmc=,size_16,color_FFFFFF,t_70) 222 | (上图为迁移学习模型的结果) 223 | 224 | # 7.拓展延伸 225 | 基于上述工作,我们可以进一步的从动漫中抠出表情包。当然这其中涉及了一些视频分解、gif合成的问题,这里不做赘述。脚本我已经写好了,此处展示一下结果。 226 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190713214956260.gif) 227 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190713215012894.gif) 228 | 可以看到效果比较不错,图中的雪花是由于gif已经过压缩。 229 | 230 | # 8.总结反思 231 | 总的来说,达到了我们较为理想的结果。但由于==数据集有限==,尽管已经通过迁移学习的方法达到了较为理想的IoU,但可以想象,如果能够有更大规模的数据集,我们一定可以得到更好的效果。 232 | 233 | # 9.尾声 234 | 可以预见,雷帅未来从事CV方向的概率比较渺茫,这可能是雷帅在CV方向探索的巅峰。尽管如此,雷帅仍然从中学到了许多东西。 235 | 236 | # 10.References 237 | [1].https://github.com/divamgupta/image-segmentation-keras 238 | [2].Jonathan Long, Evan Shelhamer ,Trevor Darrell, Fully Convolutional Networks for Semantic Segmentation, In CVPR,2015 239 | [3].Hengshuang Zhao, Jianping Shi, Xiaojuan Qi,Xiaogang Wang, Jiaya Jia ,Pyramid Scene Parsing Network, in CVPR,2017 240 | -------------------------------------------------------------------------------- /cartoon.py: -------------------------------------------------------------------------------- 1 | import keras_segmentation 2 | 3 | model = keras_segmentation.pretrained.pspnet_101_voc12() 4 | 5 | 6 | model.train( 7 | train_images = "dataset2/train_images/", 8 | train_annotations = "dataset2/train_anno/", 9 | checkpoints_path="tmp/pspnet_1", 10 | epochs=5 11 | ) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dataset2/annotations/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/1.png -------------------------------------------------------------------------------- /dataset2/annotations/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/10.png -------------------------------------------------------------------------------- /dataset2/annotations/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/11.png -------------------------------------------------------------------------------- /dataset2/annotations/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/12.png -------------------------------------------------------------------------------- /dataset2/annotations/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/13.png -------------------------------------------------------------------------------- /dataset2/annotations/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/14.png -------------------------------------------------------------------------------- /dataset2/annotations/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/15.png -------------------------------------------------------------------------------- /dataset2/annotations/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/16.png -------------------------------------------------------------------------------- /dataset2/annotations/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/17.png -------------------------------------------------------------------------------- /dataset2/annotations/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/18.png -------------------------------------------------------------------------------- /dataset2/annotations/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/19.png -------------------------------------------------------------------------------- /dataset2/annotations/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/2.png -------------------------------------------------------------------------------- /dataset2/annotations/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/20.png -------------------------------------------------------------------------------- /dataset2/annotations/21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/21.png -------------------------------------------------------------------------------- /dataset2/annotations/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/22.png -------------------------------------------------------------------------------- /dataset2/annotations/23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/23.png -------------------------------------------------------------------------------- /dataset2/annotations/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/24.png -------------------------------------------------------------------------------- /dataset2/annotations/25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/25.png -------------------------------------------------------------------------------- /dataset2/annotations/26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/26.png -------------------------------------------------------------------------------- /dataset2/annotations/27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/27.png -------------------------------------------------------------------------------- /dataset2/annotations/28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/28.png -------------------------------------------------------------------------------- /dataset2/annotations/29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/29.png -------------------------------------------------------------------------------- /dataset2/annotations/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/3.png -------------------------------------------------------------------------------- /dataset2/annotations/30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/30.png -------------------------------------------------------------------------------- /dataset2/annotations/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/4.png -------------------------------------------------------------------------------- /dataset2/annotations/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/5.png -------------------------------------------------------------------------------- /dataset2/annotations/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/6.png -------------------------------------------------------------------------------- /dataset2/annotations/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/7.png -------------------------------------------------------------------------------- /dataset2/annotations/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/8.png -------------------------------------------------------------------------------- /dataset2/annotations/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/annotations/9.png -------------------------------------------------------------------------------- /dataset2/test_anno/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/1.png -------------------------------------------------------------------------------- /dataset2/test_anno/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/10.png -------------------------------------------------------------------------------- /dataset2/test_anno/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/2.png -------------------------------------------------------------------------------- /dataset2/test_anno/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/3.png -------------------------------------------------------------------------------- /dataset2/test_anno/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/4.png -------------------------------------------------------------------------------- /dataset2/test_anno/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/5.png -------------------------------------------------------------------------------- /dataset2/test_anno/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/6.png -------------------------------------------------------------------------------- /dataset2/test_anno/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/7.png -------------------------------------------------------------------------------- /dataset2/test_anno/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/8.png -------------------------------------------------------------------------------- /dataset2/test_anno/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_anno/9.png -------------------------------------------------------------------------------- /dataset2/test_images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/1.png -------------------------------------------------------------------------------- /dataset2/test_images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/10.png -------------------------------------------------------------------------------- /dataset2/test_images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/2.png -------------------------------------------------------------------------------- /dataset2/test_images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/3.png -------------------------------------------------------------------------------- /dataset2/test_images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/4.png -------------------------------------------------------------------------------- /dataset2/test_images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/5.png -------------------------------------------------------------------------------- /dataset2/test_images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/6.png -------------------------------------------------------------------------------- /dataset2/test_images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/7.png -------------------------------------------------------------------------------- /dataset2/test_images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/8.png -------------------------------------------------------------------------------- /dataset2/test_images/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/test_images/9.png -------------------------------------------------------------------------------- /dataset2/train_anno/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/1.png -------------------------------------------------------------------------------- /dataset2/train_anno/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/10.png -------------------------------------------------------------------------------- /dataset2/train_anno/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/11.png -------------------------------------------------------------------------------- /dataset2/train_anno/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/12.png -------------------------------------------------------------------------------- /dataset2/train_anno/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/13.png -------------------------------------------------------------------------------- /dataset2/train_anno/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/14.png -------------------------------------------------------------------------------- /dataset2/train_anno/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/15.png -------------------------------------------------------------------------------- /dataset2/train_anno/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/16.png -------------------------------------------------------------------------------- /dataset2/train_anno/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/17.png -------------------------------------------------------------------------------- /dataset2/train_anno/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/18.png -------------------------------------------------------------------------------- /dataset2/train_anno/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/19.png -------------------------------------------------------------------------------- /dataset2/train_anno/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/2.png -------------------------------------------------------------------------------- /dataset2/train_anno/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/20.png -------------------------------------------------------------------------------- /dataset2/train_anno/21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/21.png -------------------------------------------------------------------------------- /dataset2/train_anno/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/22.png -------------------------------------------------------------------------------- /dataset2/train_anno/23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/23.png -------------------------------------------------------------------------------- /dataset2/train_anno/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/24.png -------------------------------------------------------------------------------- /dataset2/train_anno/25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/25.png -------------------------------------------------------------------------------- /dataset2/train_anno/26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/26.png -------------------------------------------------------------------------------- /dataset2/train_anno/27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/27.png -------------------------------------------------------------------------------- /dataset2/train_anno/28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/28.png -------------------------------------------------------------------------------- /dataset2/train_anno/29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/29.png -------------------------------------------------------------------------------- /dataset2/train_anno/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/3.png -------------------------------------------------------------------------------- /dataset2/train_anno/30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/30.png -------------------------------------------------------------------------------- /dataset2/train_anno/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/4.png -------------------------------------------------------------------------------- /dataset2/train_anno/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/5.png -------------------------------------------------------------------------------- /dataset2/train_anno/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/6.png -------------------------------------------------------------------------------- /dataset2/train_anno/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/7.png -------------------------------------------------------------------------------- /dataset2/train_anno/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/8.png -------------------------------------------------------------------------------- /dataset2/train_anno/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_anno/9.png -------------------------------------------------------------------------------- /dataset2/train_images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/1.png -------------------------------------------------------------------------------- /dataset2/train_images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/10.png -------------------------------------------------------------------------------- /dataset2/train_images/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/11.png -------------------------------------------------------------------------------- /dataset2/train_images/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/12.png -------------------------------------------------------------------------------- /dataset2/train_images/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/13.png -------------------------------------------------------------------------------- /dataset2/train_images/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/14.png -------------------------------------------------------------------------------- /dataset2/train_images/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/15.png -------------------------------------------------------------------------------- /dataset2/train_images/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/16.png -------------------------------------------------------------------------------- /dataset2/train_images/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/17.png -------------------------------------------------------------------------------- /dataset2/train_images/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/18.png -------------------------------------------------------------------------------- /dataset2/train_images/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/19.png -------------------------------------------------------------------------------- /dataset2/train_images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/2.png -------------------------------------------------------------------------------- /dataset2/train_images/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/20.png -------------------------------------------------------------------------------- /dataset2/train_images/21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/21.png -------------------------------------------------------------------------------- /dataset2/train_images/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/22.png -------------------------------------------------------------------------------- /dataset2/train_images/23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/23.png -------------------------------------------------------------------------------- /dataset2/train_images/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/24.png -------------------------------------------------------------------------------- /dataset2/train_images/25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/25.png -------------------------------------------------------------------------------- /dataset2/train_images/26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/26.png -------------------------------------------------------------------------------- /dataset2/train_images/27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/27.png -------------------------------------------------------------------------------- /dataset2/train_images/28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/28.png -------------------------------------------------------------------------------- /dataset2/train_images/29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/29.png -------------------------------------------------------------------------------- /dataset2/train_images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/3.png -------------------------------------------------------------------------------- /dataset2/train_images/30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/30.png -------------------------------------------------------------------------------- /dataset2/train_images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/4.png -------------------------------------------------------------------------------- /dataset2/train_images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/5.png -------------------------------------------------------------------------------- /dataset2/train_images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/6.png -------------------------------------------------------------------------------- /dataset2/train_images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/7.png -------------------------------------------------------------------------------- /dataset2/train_images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/8.png -------------------------------------------------------------------------------- /dataset2/train_images/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RadiumScriptTang/cartoon_segmentation/9143d181d52a407f51fbc804c03b3df939fed71b/dataset2/train_images/9.png -------------------------------------------------------------------------------- /predict.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | from keras.models import load_model 4 | import glob 5 | import cv2 6 | import numpy as np 7 | import random 8 | import os 9 | from tqdm import tqdm 10 | from .train import find_latest_checkpoint 11 | import os 12 | from .data_utils.data_loader import get_image_arr , get_segmentation_arr 13 | import json 14 | from .models.config import IMAGE_ORDERING 15 | from . import metrics 16 | from .models import model_from_name 17 | 18 | import six 19 | 20 | random.seed(0) 21 | class_colors = [ ( random.randint(0,255),random.randint(0,255),random.randint(0,255) ) for _ in range(5000) ] 22 | 23 | 24 | def model_from_checkpoint_path( checkpoints_path ): 25 | 26 | assert ( os.path.isfile(checkpoints_path+"_config.json" ) ) , "Checkpoint not found." 27 | model_config = json.loads(open( checkpoints_path+"_config.json" , "r" ).read()) 28 | latest_weights = find_latest_checkpoint( checkpoints_path ) 29 | assert ( not latest_weights is None ) , "Checkpoint not found." 30 | model = model_from_name[ model_config['model_class'] ]( model_config['n_classes'] , input_height=model_config['input_height'] , input_width=model_config['input_width'] ) 31 | print("loaded weights " , latest_weights ) 32 | model.load_weights(latest_weights) 33 | return model 34 | 35 | 36 | def predict( model=None , inp=None , out_fname=None , checkpoints_path=None ): 37 | 38 | if model is None and ( not checkpoints_path is None ): 39 | model = model_from_checkpoint_path(checkpoints_path) 40 | 41 | assert ( not inp is None ) 42 | assert( (type(inp) is np.ndarray ) or isinstance( inp , six.string_types) ) , "Inupt should be the CV image or the input file name" 43 | 44 | if isinstance( inp , six.string_types) : 45 | inp = cv2.imread(inp ) 46 | 47 | assert len(inp.shape) == 3 , "Image should be h,w,3 " 48 | orininal_h = inp.shape[0] 49 | orininal_w = inp.shape[1] 50 | 51 | 52 | output_width = model.output_width 53 | output_height = model.output_height 54 | input_width = model.input_width 55 | input_height = model.input_height 56 | n_classes = model.n_classes 57 | 58 | x = get_image_arr( inp , input_width , input_height , odering=IMAGE_ORDERING ) 59 | pr = model.predict( np.array([x]) )[0] 60 | pr = pr.reshape(( output_height , output_width , n_classes ) ).argmax( axis=2 ) 61 | 62 | seg_img = np.zeros( ( output_height , output_width , 3 ) ) 63 | colors = class_colors 64 | 65 | for c in range(n_classes): 66 | seg_img[:,:,0] += ( (pr[:,: ] == c )*( colors[c][0] )).astype('uint8') 67 | seg_img[:,:,1] += ((pr[:,: ] == c )*( colors[c][1] )).astype('uint8') 68 | seg_img[:,:,2] += ((pr[:,: ] == c )*( colors[c][2] )).astype('uint8') 69 | 70 | seg_img = cv2.resize(seg_img , (orininal_w , orininal_h )) 71 | 72 | if not out_fname is None: 73 | cv2.imwrite( out_fname , seg_img ) 74 | 75 | 76 | return pr 77 | 78 | 79 | def predict_multiple( model=None , inps=None , inp_dir=None, out_dir=None , checkpoints_path=None ): 80 | 81 | if model is None and ( not checkpoints_path is None ): 82 | model = model_from_checkpoint_path(checkpoints_path) 83 | 84 | 85 | if inps is None and ( not inp_dir is None ): 86 | inps = glob.glob( os.path.join(inp_dir,"*.jpg") ) + glob.glob( os.path.join(inp_dir,"*.png") ) + glob.glob( os.path.join(inp_dir,"*.jpeg") ) 87 | 88 | assert type(inps) is list 89 | 90 | all_prs = [] 91 | 92 | for i , inp in enumerate(tqdm(inps)): 93 | if out_dir is None: 94 | out_fname = None 95 | else: 96 | if isinstance( inp , six.string_types) : 97 | out_fname = os.path.join( out_dir , os.path.basename(inp) ) 98 | else : 99 | out_fname = os.path.join( out_dir , str(i)+ ".jpg" ) 100 | 101 | pr = predict(model , inp ,out_fname ) 102 | all_prs.append( pr ) 103 | 104 | return all_prs 105 | 106 | 107 | 108 | 109 | def evaluate( model=None , inp_images=None , annotations=None , checkpoints_path=None ): 110 | 111 | # assert False , "not implemented " 112 | 113 | names = os.listdir(inp_images) 114 | images_annotations = [(os.path.join(inp_images,name),os.path.join(annotations,name)) for name in names] 115 | 116 | ious = [] 117 | for inp , ann in images_annotations: 118 | pr = predict(model , inp ) 119 | gt = get_segmentation_arr( ann , model.n_classes , model.output_width , model.output_height ) 120 | gt = gt.argmax(-1) 121 | gt = gt.reshape((96,144)) 122 | iou = metrics.get_iou( gt , pr , model.n_classes ) 123 | ious.append( iou ) 124 | ious = np.array( ious ) 125 | print("Class wise IoU " , np.mean(ious , axis=0 )) 126 | print("Total IoU " , np.mean(ious )) 127 | 128 | 129 | -------------------------------------------------------------------------------- /show.py: -------------------------------------------------------------------------------- 1 | import keras_segmentation 2 | import cv2 3 | import os 4 | 5 | def output_segmentations(model,inp=None,outp=None): 6 | assert inp and outp,"None type inp and outp is not allowed" 7 | names = os.listdir(inp) 8 | for name in names: 9 | model.predict_segmentation(inp=os.path.join(inp,name),out_fname=os.path.join(outp,name)) 10 | img = cv2.imread(os.path.join(outp,name)) 11 | img_origin = cv2.imread(os.path.join(inp,name)) 12 | h, w, c = img.shape 13 | for i in range(h): 14 | for j in range(w): 15 | if img[i, j, 0] == 197: 16 | img_origin[i, j] = 255 17 | cv2.imwrite(os.path.join(outp,"seg_"+name),img_origin) 18 | 19 | if __name__ == "__main__": 20 | model = keras_segmentation.predict.model_from_checkpoint_path("tmp/pspnet_1") 21 | output_segmentations(model,"dataset2/test_images","outputs") --------------------------------------------------------------------------------