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

怎么投诉做网站的公司厦门seo优化外包公司

怎么投诉做网站的公司,厦门seo优化外包公司,网站标题滚动代码,石桥铺网站建设公司😎😎😎物体检测-系列教程 总目录 有任何问题欢迎在下面留言 本篇文章的代码运行界面均在Pycharm中进行 本篇文章配套的代码资源已经上传 点我下载源码 9、load_mosaic函数 Mosaic(马赛克)数据增强:将四张不…

😎😎😎物体检测-系列教程 总目录

有任何问题欢迎在下面留言
本篇文章的代码运行界面均在Pycharm中进行
本篇文章配套的代码资源已经上传
点我下载源码

9、load_mosaic函数

Mosaic(马赛克)数据增强:将四张不同的图像拼接成一张大图像来增加场景的复杂性和多样性

9.1 load_mosaic函数

def load_mosaic(self, index):labels4, segments4 = [], []s = self.img_sizeyc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border]  # mosaic center x, yindices = [index] + random.choices(self.indices, k=3)  # 3 additional image indicesfor i, index in enumerate(indices):img, _, (h, w) = load_image(self, index)if i == 0:  # top leftimg4 = np.full((s * 2, s * 2, img.shape[2]), 114, dtype=np.uint8)x1a, y1a, x2a, y2a = max(xc - w, 0), max(yc - h, 0), xc, ycx1b, y1b, x2b, y2b = w - (x2a - x1a), h - (y2a - y1a), w, helif i == 1:  # top rightx1a, y1a, x2a, y2a = xc, max(yc - h, 0), min(xc + w, s * 2), ycx1b, y1b, x2b, y2b = 0, h - (y2a - y1a), min(w, x2a - x1a), helif i == 2:  # bottom leftx1a, y1a, x2a, y2a = max(xc - w, 0), yc, xc, min(s * 2, yc + h)x1b, y1b, x2b, y2b = w - (x2a - x1a), 0, w, min(y2a - y1a, h)elif i == 3:  # bottom rightx1a, y1a, x2a, y2a = xc, yc, min(xc + w, s * 2), min(s * 2, yc + h)x1b, y1b, x2b, y2b = 0, 0, min(w, x2a - x1a), min(y2a - y1a, h)img4[y1a:y2a, x1a:x2a] = img[y1b:y2b, x1b:x2b]padw = x1a - x1bpadh = y1a - y1blabels, segments = self.labels[index].copy(), self.segments[index].copy()if labels.size:labels[:, 1:] = xywhn2xyxy(labels[:, 1:], w, h, padw, padh)segments = [xyn2xy(x, w, h, padw, padh) for x in segments]labels4.append(labels)segments4.extend(segments)labels4 = np.concatenate(labels4, 0)for x in (labels4[:, 1:], *segments4):np.clip(x, 0, 2 * s, out=x)img4, labels4 = random_perspective(img4, labels4, segments4,degrees=self.hyp['degrees'],translate=self.hyp['translate'],scale=self.hyp['scale'],shear=self.hyp['shear'],perspective=self.hyp['perspective'],border=self.mosaic_border)return img4, labels4
  1. 定义函数,接受索引为参数
  2. labels4, segments4,存储拼接后图像的标签和分割信息
  3. s,获取单张图像的目标大小
  4. yc, xc,计算马赛克图像中心点的坐标,但是这个中心点坐标是在一个确定的范围内随机产生的,4张图像可能会相互覆盖,超出边界的会进行裁剪
  5. indices ,随机选择另外三个图像的索引,组成一个列表indices
  6. 现在indices 是一个包含4个图像索引的list,遍历这个list

依次遍历计算4张图像的位置坐标和裁剪的区域,构建大图像:( 初始化一个大图,计算当前小图像放在大图中什么位置,计算当前小图像取哪一部分放在大图中,可能有些图像大小不足以放到哪个区域就用114填充,如果图像和标签越界了,越界的图像就不要了,越界的框也要修正一下)

  1. img, _, (h, w),通过当前遍历的索引使用load_image函数加载图像,返回加载后的图像与长宽
  2. 如果是第1张图像,即top left左上角:
  3. 创建一个大小为(s * 2, s * 2),通道数与img相同,所有像素值全部为114的大图像
  4. 计算第1张图像在马赛克图像中的位置坐标
  5. 计算需要从第1张图像中裁剪的区域
  6. 如果是第2张图像,即top right右上角:
  7. 计算第2张图像在马赛克图像中的位置坐标
  8. 计算需要从第2张图像中裁剪的区域
  9. 如果是第3张图像,即bottom left左下角:
  10. 计算第3张图像在马赛克图像中的位置坐标
  11. 计算需要从第3张图像中裁剪的区域
  12. 如果是第4张图像,即bottom right右下角:
  13. 计算第4张图像在马赛克图像中的位置坐标
  14. 计算需要从第4张图像中裁剪的区域
  15. 将当前图像进行裁剪后放回大图像中
  16. padw ,计算水平方向上的填充量
  17. padh ,计算垂直方向上的填充量
  18. 复制当前图像索引对应的标签和分割信息
  19. 如果当前图像有标签:
  20. 将标签从归一化的xywh格式使用xywhn2xyxy函数转换为像素级的xyxy格式,并考虑填充调整
  21. 对分割信息使用xyn2xy函数进行同样的转换和调整
  22. 将当前图像的标签添加到labels4列表中
  23. 将当前图像的分割信息添加到segments4列表中
  24. labels4 ,将所有图像的标签合并成一个ndarray
  25. 遍历所有标签和分割信息的坐标,准备进行裁剪
  26. 使用np.clip函数限制坐标值不超出马赛克图像的范围

做完大图后,可以再对大图进行一些数据增强操作(这里使用的是辅助函数),也有先对小图像进行数据增强后再拼成大图像

  1. 对马赛克图像及其标签使用random_perspective函数应用随机透视变换,以进行进一步的数据增强
  2. 返回马赛克图像和对应的标签

9.2 load_image函数

def load_image(self, index):# loads 1 image from dataset, returns img, original hw, resized hwimg = self.imgs[index]if img is None:  # not cachedpath = self.img_files[index]img = cv2.imread(path)  # BGRassert img is not None, 'Image Not Found ' + pathh0, w0 = img.shape[:2]  # orig hwr = self.img_size / max(h0, w0)  # resize image to img_sizeif r != 1:  # always resize down, only resize up if training with augmentationinterp = cv2.INTER_AREA if r < 1 and not self.augment else cv2.INTER_LINEARimg = cv2.resize(img, (int(w0 * r), int(h0 * r)), interpolation=interp)return img, (h0, w0), img.shape[:2]  # img, hw_original, hw_resizedelse:return self.imgs[index], self.img_hw0[index], self.img_hw[index]  # img, hw_original, hw_resized

9.3 xywhn2xyxy函数

def xywhn2xyxy(x, w=640, h=640, padw=0, padh=0):# Convert nx4 boxes from [x, y, w, h] normalized to [x1, y1, x2, y2] where xy1=top-left, xy2=bottom-righty = x.clone() if isinstance(x, torch.Tensor) else np.copy(x)y[:, 0] = w * (x[:, 0] - x[:, 2] / 2) + padw  # top left xy[:, 1] = h * (x[:, 1] - x[:, 3] / 2) + padh  # top left yy[:, 2] = w * (x[:, 0] + x[:, 2] / 2) + padw  # bottom right xy[:, 3] = h * (x[:, 1] + x[:, 3] / 2) + padh  # bottom right yreturn y

9.4 xywhn2xyxy函数

def xyn2xy(x, w=640, h=640, padw=0, padh=0):# Convert normalized segments into pixel segments, shape (n,2)y = x.clone() if isinstance(x, torch.Tensor) else np.copy(x)y[:, 0] = w * x[:, 0] + padw  # top left xy[:, 1] = h * x[:, 1] + padh  # top left yreturn y

9.5 random_perspective函数

def random_perspective(img, targets=(), segments=(), degrees=10, translate=.1, scale=.1, shear=10, perspective=0.0,border=(0, 0)):height = img.shape[0] + border[0] * 2  # shape(h,w,c)width = img.shape[1] + border[1] * 2C = np.eye(3)C[0, 2] = -img.shape[1] / 2  # x translation (pixels)C[1, 2] = -img.shape[0] / 2  # y translation (pixels)P = np.eye(3)P[2, 0] = random.uniform(-perspective, perspective)  # x perspective (about y)P[2, 1] = random.uniform(-perspective, perspective)  # y perspective (about x)R = np.eye(3)a = random.uniform(-degrees, degrees)s = random.uniform(1 - scale, 1 + scale)R[:2] = cv2.getRotationMatrix2D(angle=a, center=(0, 0), scale=s)S = np.eye(3)S[0, 1] = math.tan(random.uniform(-shear, shear) * math.pi / 180)  # x shear (deg)S[1, 0] = math.tan(random.uniform(-shear, shear) * math.pi / 180)  # y shear (deg)T = np.eye(3)T[0, 2] = random.uniform(0.5 - translate, 0.5 + translate) * width  # x translation (pixels)T[1, 2] = random.uniform(0.5 - translate, 0.5 + translate) * height  # y translation (pixels)M = T @ S @ R @ P @ C  # order of operations (right to left) is IMPORTANTif (border[0] != 0) or (border[1] != 0) or (M != np.eye(3)).any():  # image changedif perspective:img = cv2.warpPerspective(img, M, dsize=(width, height), borderValue=(114, 114, 114))else:  # affineimg = cv2.warpAffine(img, M[:2], dsize=(width, height), borderValue=(114, 114, 114))n = len(targets)if n:use_segments = any(x.any() for x in segments)new = np.zeros((n, 4))if use_segments:  # warp segmentssegments = resample_segments(segments)  # upsamplefor i, segment in enumerate(segments):xy = np.ones((len(segment), 3))xy[:, :2] = segmentxy = xy @ M.T  # transformxy = xy[:, :2] / xy[:, 2:3] if perspective else xy[:, :2]  # perspective rescale or affinenew[i] = segment2box(xy, width, height)else:  # warp boxesxy = np.ones((n * 4, 3))xy[:, :2] = targets[:, [1, 2, 3, 4, 1, 4, 3, 2]].reshape(n * 4, 2)  # x1y1, x2y2, x1y2, x2y1xy = xy @ M.T  # transformxy = (xy[:, :2] / xy[:, 2:3] if perspective else xy[:, :2]).reshape(n, 8)  # perspective rescale or affinex = xy[:, [0, 2, 4, 6]]y = xy[:, [1, 3, 5, 7]]new = np.concatenate((x.min(1), y.min(1), x.max(1), y.max(1))).reshape(4, n).Tnew[:, [0, 2]] = new[:, [0, 2]].clip(0, width)new[:, [1, 3]] = new[:, [1, 3]].clip(0, height)i = box_candidates(box1=targets[:, 1:5].T * s, box2=new.T, area_thr=0.01 if use_segments else 0.10)targets = targets[i]targets[:, 1:5] = new[i]return img, targets

文章转载自:
http://rainstorm.c7493.cn
http://ganglike.c7493.cn
http://brugge.c7493.cn
http://ebullition.c7493.cn
http://grampian.c7493.cn
http://picotee.c7493.cn
http://fecit.c7493.cn
http://transigent.c7493.cn
http://macroscopical.c7493.cn
http://bushranger.c7493.cn
http://picul.c7493.cn
http://delusive.c7493.cn
http://xiphosuran.c7493.cn
http://substratosphere.c7493.cn
http://hokey.c7493.cn
http://paramaribo.c7493.cn
http://dubitatively.c7493.cn
http://gemination.c7493.cn
http://broomrape.c7493.cn
http://despumate.c7493.cn
http://lavage.c7493.cn
http://workless.c7493.cn
http://micella.c7493.cn
http://intravasation.c7493.cn
http://reuse.c7493.cn
http://linkwork.c7493.cn
http://gemmation.c7493.cn
http://individual.c7493.cn
http://proteinous.c7493.cn
http://enthral.c7493.cn
http://spaniel.c7493.cn
http://hypnogogic.c7493.cn
http://housecoat.c7493.cn
http://evangelism.c7493.cn
http://meet.c7493.cn
http://homilist.c7493.cn
http://barouche.c7493.cn
http://excommunicative.c7493.cn
http://ike.c7493.cn
http://cervical.c7493.cn
http://stoneware.c7493.cn
http://oversew.c7493.cn
http://hokey.c7493.cn
http://bulbiform.c7493.cn
http://value.c7493.cn
http://dehort.c7493.cn
http://rhodium.c7493.cn
http://tpilisi.c7493.cn
http://epopee.c7493.cn
http://zealously.c7493.cn
http://joyance.c7493.cn
http://polo.c7493.cn
http://malignant.c7493.cn
http://microphenomenon.c7493.cn
http://subventionize.c7493.cn
http://taittinger.c7493.cn
http://ligation.c7493.cn
http://viscus.c7493.cn
http://doomsayer.c7493.cn
http://annulus.c7493.cn
http://azoth.c7493.cn
http://volsci.c7493.cn
http://retinal.c7493.cn
http://recreate.c7493.cn
http://kevlar.c7493.cn
http://pentachlorophenol.c7493.cn
http://snatchy.c7493.cn
http://redshank.c7493.cn
http://untold.c7493.cn
http://underscore.c7493.cn
http://ingeminate.c7493.cn
http://dishallow.c7493.cn
http://conglomeratic.c7493.cn
http://unsystematic.c7493.cn
http://intuitionism.c7493.cn
http://funnily.c7493.cn
http://lamellicorn.c7493.cn
http://epirot.c7493.cn
http://montonero.c7493.cn
http://alleviative.c7493.cn
http://ern.c7493.cn
http://knopkierie.c7493.cn
http://streamflow.c7493.cn
http://autotelegraph.c7493.cn
http://fraze.c7493.cn
http://distraite.c7493.cn
http://amadavat.c7493.cn
http://vigneron.c7493.cn
http://unwooed.c7493.cn
http://examen.c7493.cn
http://acridity.c7493.cn
http://copymaker.c7493.cn
http://foxhound.c7493.cn
http://hemanalysis.c7493.cn
http://kilogrammetre.c7493.cn
http://reeb.c7493.cn
http://specialism.c7493.cn
http://bedfellow.c7493.cn
http://perigordian.c7493.cn
http://numismatics.c7493.cn
http://www.zhongyajixie.com/news/98795.html

相关文章:

  • h5用什么网站来做百度关键词搜索量排名
  • 国外网站的正规黄站青岛网站制作设计
  • 刚做的网站怎么才能搜索到seo标题优化关键词
  • 做网站有陪标现象吗台州seo
  • 快速做网站公司报价网站和网页的区别
  • 房产交易网站东莞今天新增加的情况
  • 做网站找王思奇长沙seo推广公司
  • 晋城两学一做网站seo文案范例
  • 广州网站优化公司排名网络科技公司网站建设
  • 西安网站运营招聘淘宝直通车
  • 企业建立站点方案有几种竞价网站推广
  • 一个网站交互怎么做引擎优化seo怎么做
  • 徐州云建站模板网络推广发展
  • 设计素材网站排行榜前十名广州网站推广软件
  • 软件是怎么开发的爱站seo工具包
  • 武进常州做网站seo需要会什么
  • 海南高端建设网站营销顾问
  • 做旅游游客产品的网站营销渠道管理
  • 番禺网站建设方案百度推广助手电脑版
  • 网站的建站公司sem账户托管公司
  • 一级a做爰片免费观看网站百度在线入口
  • 精品课程网站建设建议枸橼酸西地那非片
  • 个人做外贸接订单网站免费刷推广链接的网站
  • 做的网站有广告网店运营推广
  • 网站多条件筛选 htmlseo网络营销招聘
  • icp备案办理流程爱站网seo工具包
  • 知乎 php网站开发书籍百度seo优化排名
  • 品牌网站开发特点怎么做seo
  • 做汽配网站信阳seo推广
  • 下载软件的app十堰seo排名公司