首页 > 编程知识 正文

随机系数模型,随机效应模型解读

时间:2023-05-03 09:12:39 阅读:113946 作者:516

PSENet输入imgs是包含img、gt_text、training_mask和gt_kernels的列表。 其中img是原始图像,gt_text背景为0的文本区域的值是文本实例索引;例如,如果有三行文本,则相应的文本区域将分别填充1、2和3。 training_mask是标签为“#”,即忽略文本行区域为0,其馀地方的值为1的二值图,gt_kernels共有6张图是与文本区域shrink的不同比例相对应的二值图。 psenet是基于语义分割的模型,标签与模型输入大小相同,因此对原图进行反转、旋转、裁剪等操作,对标签也进行同样的操作即可。

importnumpyasnpimportrandomdefrandom _ crop (imgs,img_size ) : # imgs=[img,gt_text,training _ mask ] # ii tw=img_size # 640, 640 ifw==tw andh==th : returnimgsifrandom.random (3.0/8.0 andnp.max ) imgs[1] ) 0: #按一定比例进行复制,并在img上文本确保存在axis=1)- img_size #的是文本区域TL文本区域TL,该文本区域TL在所有Box中可以包括至少一个像素,只要找到最左边和最上面的坐标# -640的TL大于0即可0 ),axis=1) -如果确保-img_sizebr[br0]=0br[0]=的br较小,且确保将起点选择到右下边界,则crop区域的左上方可以包括至少一个像素j是起点i=random.randint(tl[0],br[0] ) j的br[1] ) else:I=random.randint(0,h - th ) j=random.random twforidxinrange(len(imgs ) ) :iflen ) imgs [ idx ]=3: imgs [ idx ] [ I 3360 ith,j33660I 3360 j : j tw ]返回imgs EAST的核心思想是横跨图中的所有地面轨迹,包括不包含文本区域的所有x和y坐标、crop,以及east中以一定比例不包含crop中文本的纯背景样本

importnumpyasnpmin _ crop _ side _ ratio=0.1 def crop _ area (im、polys、tags、crop_background=False, max_tries=50 ) 3360 ' ' ' makerandomcropfromtheinputimage : paramim :3360 param polys : param tags 336033603360 param crop _ backgroun nt mmmmm h,w,_=im.shape # pad_h和pad_w似乎不太使用pad_h=h///10pad_w=w//10 ) w _ array decimals=0).astype(NP.int32 ) minx=NP.min ) poly [ :0 ];maxx=NP.max (poly [ :0 ],0 ),w _ 1] ) maxy=NP.max ) poly [ :1 ], 1 ) h _ array [ miny pad _ h : maxy pad _ h ]=1# ensurethecroppedareanotacrossatexth _ axis=NP.where (不包含h _ array文本区域的y坐标w_axis=NP.where(w_array==0(0) pollen tagsforiinrange (max _ tries ) :xx=NP.random.choice ) w_axis,size=2) xmin=NP.min ) xx-pad _ ce h-1 ) ymax=NP.clip(ymax,0,h-1 ) if xmax-x minmin _ crop _ side _ ratio * wory max-y minmin _ crop _ side _ y=0: poly _ axis _ in _ area=(polys [ :0 ]=xmin ) polys [ :0 ]=xmax ) ) 1 )=ymax(selected_polys=NP.where ) NP.sum ) poly_axis_in_area, axis=1(=4) [0] else : selected_polys=[ ] if len ) selected _ polys )==0: # notextinthisareaifcrop _ baction :],polys[selected_polys],tags [ selected _ polys ] else : continueim=im [ ymin : ymax 1,xmin:xmax 1 3360 ) polys=polys [ selected _ polys ] tags=tags [ selected _ polys ] polys [ :0 ]-=xmin polys [ 3360 ]

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。