当前位置: 首页 > news >正文

淘宝网站建设没法上传怎么办社交网站制作

淘宝网站建设没法上传怎么办,社交网站制作,天津建设银行公积金缴费官方网站,2345网址导航怎么下载软件在对数据或特征的处理中#xff0c;为了避免输入图像或特征#xff0c;经过resize等等操作#xff0c;改变了目标特征的尺度信息#xff0c;一般会引入一些操作#xff0c;比如#xff1a; 在特征维度#xff0c;加入SPP#xff08;空间金字塔池化#xff09;#x…在对数据或特征的处理中为了避免输入图像或特征经过resize等等操作改变了目标特征的尺度信息一般会引入一些操作比如 在特征维度加入SPP空间金字塔池化这样不同大小的输入图像经过该层的处理输出大小都保持了一致在输入图像阶段也可以先采用pad的操作补齐输入图像避免变形 本文就是借鉴yolo系列对输入图像前处理的一个操作对不同大小的图像先经过长边等比例resize后pad到一样大小的尺寸。 具体的操作代码如下 import cv2 import numpy as np import matplotlib.pyplot as plt import xml.etree.ElementTree as ETdef parse_xml(path):tree ET.parse(path)root tree.findall(object)class_list []boxes_list []for sub in root:xmin float(sub.find(bndbox).find(xmin).text)xmax float(sub.find(bndbox).find(xmax).text)ymin float(sub.find(bndbox).find(ymin).text)ymax float(sub.find(bndbox).find(ymax).text)boxes_list.append([xmin, ymin, xmax, ymax])class_list.append(sub.find(name).text)return class_list, np.array(boxes_list).astype(np.int32)def letterbox(img, new_shape(640, 640), color(114, 114, 114), autoTrue, scaleFillFalse, scaleupTrue, stride32):用于将输入的图像进行长边resize和填充以满足一定的约束条件。函数的输入参数包括im输入的图像可以是任意尺寸和通道数的numpy数组。new_shape目标尺寸可以是一个整数或一个元组。如果是一个整数则表示将图像resize成一个正方形如果是一个元组则表示将图像resize成指定的宽度和高度。color填充颜色可以是一个整数或一个元组。如果是一个整数则表示使用灰度值为该整数的像素进行填充如果是一个元组则表示使用RGB颜色值进行填充。auto是否启用自动计算填充大小。如果为True则会根据指定的stride值计算最小的填充大小以满足长宽比和stride倍数的约束条件如果为False则会根据指定的scaleFill和scaleup参数计算填充大小。scaleFill是否启用拉伸填充。如果为True则会拉伸图像以填满目标尺寸如果为False则会根据指定的scaleup参数决定是否缩放图像。scaleup是否允许放大图像。如果为True则允许将输入图像放大到目标尺寸如果为False则只能将输入图像缩小到目标尺寸。stridestride值用于计算最小填充大小。# Resize image to a 32-pixel-multiple rectangle https://github.com/ultralytics/yolov3/issues/232shape img.shape[:2] # current shape [height, width]if isinstance(new_shape, int):new_shape (new_shape, new_shape)# Scale ratio (new / old)r min(new_shape[0] / shape[0], new_shape[1] / shape[1]) # 短边ratioif not scaleup: # only scale down, do not scale up (for better test mAP)r min(r, 1.0)# Compute paddingratio r, r # width, height ratiosnew_unpad int(round(shape[1] * r)), int(round(shape[0] * r))dw, dh new_shape[1] - new_unpad[0], new_shape[0] - new_unpad[1] # wh paddingif auto: # minimum rectangledw, dh np.mod(dw, 64), np.mod(dh, 64) # wh paddingelif scaleFill: # stretchdw, dh 0.0, 0.0new_unpad (new_shape[1], new_shape[0])ratio new_shape[1] / shape[1], new_shape[0] / shape[0] # width, height ratiosdw / 2 # divide padding into 2 sidesdh / 2if shape[::-1] ! new_unpad: # resizeimg cv2.resize(img, new_unpad, interpolationcv2.INTER_LINEAR)top, bottom int(round(dh - 0.1)), int(round(dh 0.1))left, right int(round(dw - 0.1)), int(round(dw 0.1))img cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, valuecolor) # add borderreturn img, ratio, (dw, dh)def main(imgPath, drawBox_flag True):xmlPath imgPath[:-3] xmlprint(xmlPath, imgPath)img cv2.imread(imgPath)labels, boxes parse_xml(xmlPath)print(labels, boxes)img2, ratio, pad letterbox(img.copy(), new_shape(512, 512), autoFalse, scaleupTrue)sample1 img.copy() # origin imagesample2 img2.copy() # after letterbox imageprint(sample1.shape, sample2.shape)if drawBox_flag:new_boxes np.zeros_like(boxes)new_boxes[:, 0] ratio[0] * boxes[:, 0] pad[0] # pad widthnew_boxes[:, 1] ratio[1] * boxes[:, 1] pad[1] # pad heightnew_boxes[:, 2] ratio[0] * boxes[:, 2] pad[0]new_boxes[:, 3] ratio[1] * boxes[:, 3] pad[1]print(new_boxes)for box in boxes:cv2.rectangle(sample1, (box[0], box[1]), (box[2], box[3]), (255, 0, 0), 1)for box_n in new_boxes:cv2.rectangle(sample2, (box_n[0], box_n[1]), (box_n[2], box_n[3]), (0, 255, 0), 1)plt.subplot(121)plt.imshow(sample1)plt.subplot(122)plt.imshow(sample2)plt.show()# cv2.imwrite(rF:\labelImg\1.jpg, sample1)# cv2.imwrite(rF:\labelImg\2.jpg, sample2)if __name__ __main__:imgPath rF:\labelImg\catDog.jpgmain(imgPath, drawBox_flagTrue)展示结果如下 上面图像的尺寸比较的大超过了512大小。而低于小于512大小的图像是如何的呢 scaleup是否允许放大图像。 如果为True则允许将输入图像放大到目标尺寸如果为False则只能将输入图像缩小到目标尺寸。 当scaleupFalse时如下可以发现原始图像并没有被放大而是直接pad操作了。这是因为为scaleupFalse时只能将输入图像缩小到目标尺寸无法先放大操作 而当scaleupTrue时如下就发现他是先放大然后再进行pad操作 可以发现 scaleup设定为False时候只会对大于new shape的图像进行缩放pad当为True时就不在only scale down, do not scale up了适用的范围更广。注释里面说是为了better test mAP。
http://www.dnsts.com.cn/news/148063.html

相关文章:

  • 服装网站建设优点有哪些微博营销的优势和劣势
  • 网站实名认证功能怎么做企业网站的优劣势
  • wordpress加载转圈appstore关键词优化
  • 优化官方网站设计企业在公司做的网站看不到
  • 网站结构逻辑结构中国建筑第八工程局有限公司
  • 网络做网站如何盈利长春网站推广优化公司
  • 网站建设客户需要做网站设计
  • 社区网站制作企业信用管理系统
  • 河北城乡建设部网站首页毕业设计做网站答辩
  • wordpress 展示模板下载微信搜一搜排名优化
  • 西安企业网站做打鱼网站需要多少钱
  • 网站怎样做域名绑定电子工程师证怎么考
  • 徐州学习网站建设公司起名自动生成器
  • wordpress 大型网站吗有没有专门做纸箱的网站
  • 建筑行业一般在哪个网站招聘易橙云做的网站怎么样
  • 手机上做整蛊网站湛江建站服务
  • 网站模板修改教程惠州行业网站设计方案
  • 猫扑网站开发的网游wordpress 获取微博
  • 做网站服务器需要自己提供吗石家庄网络建设
  • 做网站需要什么知识哪个网站可以做曝光台
  • 自己做qq头像静态的网站wordpress目录导航主题
  • 建湖网站建设芜湖百度seo
  • 漫画做视频在线观看网站重庆做营销网站
  • 开发网站用什么语言最好吗怎样做市场营销策划
  • 专业模板建站公司全网网络营销推广
  • 开发网站的硬件成本wordpress自动封面
  • 网站建设用户需求wordpress aplayer
  • 公司网站后台网站实名认证中心
  • 高校网站建设的重要性建设网站哪个便宜
  • 音乐网站建设论文自适应网站建设