發表文章

目前顯示的是 3月, 2022的文章

了解逆捲積的原理

圖片
  逆卷积的详细解释ConvTranspose2d(fractionally-strided convolutions) 1.首先先定义进行卷积的参数: 输入特征图为高宽一样的H in *H in 大小的x 卷积核大小kernel_size 步长stride padding填充数(填充0) 输出特征图为H out *H out 大小的y 计算式子为: H out  =  floor( H in  + 2*padding - kernel_size / stride) + 1   2.然后实现上面的卷积的转置卷积 定义其参数为:   输入特征图为高宽一样的H out *H out 大小的y 卷积核大小kernel_size 步长stride padding new  填充数(填充0) 输出特征图为H in *H in 大小的x   逆卷积的过程主要分两步: 对输入的特征图y进行变换,得到新的特征图y new 内部变换,与卷积时设置的stride相关 外部变换,与卷积时设置的padding相关 根据得到的特征图进行卷积即可 1)对输入的特征图y进行变换,得到新的特征图y new 1》内部变换 当卷积时设置的stride>1时,将对输入的特征图y进行插值操作(interpolation)。 即需要在输入的特征图y的每个相邻值之间插入(stride-1)行和列0,因为特征图中能够插入的相邻位置有(height-1)个位置,所以此时得到的特征图的大小由H out *H out (H out 即height) 变为新的 H out_new *H out_new ,即[H out  + (stride-1) * (H out -1)] * [H out  + (stride-1) * (H out -1)]   2》外部变换 为了实现由H out *H out 大小的y逆卷积得到H in *H in 大小的x,还需要设置padding new 的值为(kernel_size - padding - 1), 这里的padding是卷积操作时设置的padding值 所以计算式子变为: H in  =  floor( [H out_n...

File "pycocotools/_mask.pyx", line 307, in pycocotools._mask.frPyObjects Exception: input type is not supported.

 mmdetection在訓練有segmentation資料的時候,發生 File "pycocotools/_mask.pyx", line 307, in pycocotools._mask.frPyObjects Exception: input type is not supported. 主要原因為自製的segmentation資料中,可能有不符合規則的資料,coco格式中,segmentation的格式為list(list(x,y,x,y,....))每個seg至少要有四個值且必須為偶數。 下列code移除不符規定的seg def check_coco_seg_format(json_path):     """     check there is invalid segmentation data in coco json file and remove invalid seg then resave it     Args:         json_path: path to json file     Returns: None     """     with open(json_path) as fid:         json_data = json.load(fid)     annotations = json_data['annotations']     for annotation in tqdm(annotations):         segs = annotation['segmentation']         new_segs = []         for seg in segs:             len_seg = len(seg)       ...