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

怎么投诉做网站的公司女教师网课入侵录屏

怎么投诉做网站的公司,女教师网课入侵录屏 ,网站设计首页,墨刀可以做网站原型图吗😎😎😎物体检测-系列教程 总目录 有任何问题欢迎在下面留言 本篇文章的代码运行界面均在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://dinncobulkiness.ydfr.cn
http://dinncomicroalloy.ydfr.cn
http://dinncovitaminology.ydfr.cn
http://dinncoreexhibit.ydfr.cn
http://dinncovirbius.ydfr.cn
http://dinncomegatanker.ydfr.cn
http://dinncotrover.ydfr.cn
http://dinncojejunectomy.ydfr.cn
http://dinncoswink.ydfr.cn
http://dinncoovipara.ydfr.cn
http://dinncoimmovability.ydfr.cn
http://dinncorelisten.ydfr.cn
http://dinncoaquarist.ydfr.cn
http://dinncoencumbrancer.ydfr.cn
http://dinncotoolkit.ydfr.cn
http://dinncoinvolvement.ydfr.cn
http://dinncostrangeness.ydfr.cn
http://dinncosplatter.ydfr.cn
http://dinncotyrtaeus.ydfr.cn
http://dinncoendexine.ydfr.cn
http://dinncoatabrine.ydfr.cn
http://dinncodecarburization.ydfr.cn
http://dinncopersiennes.ydfr.cn
http://dinncobarebacked.ydfr.cn
http://dinncofun.ydfr.cn
http://dinncomink.ydfr.cn
http://dinncostrychnin.ydfr.cn
http://dinncoconsistory.ydfr.cn
http://dinncolatine.ydfr.cn
http://dinncosyph.ydfr.cn
http://dinncounmined.ydfr.cn
http://dinncoworsted.ydfr.cn
http://dinncohdcopy.ydfr.cn
http://dinncopraia.ydfr.cn
http://dinncocusec.ydfr.cn
http://dinncopokelogan.ydfr.cn
http://dinncoscutari.ydfr.cn
http://dinncogeorge.ydfr.cn
http://dinncosmacksman.ydfr.cn
http://dinncocrescive.ydfr.cn
http://dinncomacroptic.ydfr.cn
http://dinncomontserrat.ydfr.cn
http://dinncorespirability.ydfr.cn
http://dinncofritting.ydfr.cn
http://dinncoartisanship.ydfr.cn
http://dinncocollusion.ydfr.cn
http://dinncoudometer.ydfr.cn
http://dinncosilicule.ydfr.cn
http://dinncoradiophone.ydfr.cn
http://dinncothorp.ydfr.cn
http://dinncocarmela.ydfr.cn
http://dinncopneumoencephalogram.ydfr.cn
http://dinncohelophyte.ydfr.cn
http://dinncochangjiang.ydfr.cn
http://dinnconailless.ydfr.cn
http://dinncodooryard.ydfr.cn
http://dinncokonstanz.ydfr.cn
http://dinncospaceway.ydfr.cn
http://dinncodictatorial.ydfr.cn
http://dinncotribunitian.ydfr.cn
http://dinncoablator.ydfr.cn
http://dinncooliguresis.ydfr.cn
http://dinncoorotund.ydfr.cn
http://dinncochechia.ydfr.cn
http://dinncobailie.ydfr.cn
http://dinncoabstain.ydfr.cn
http://dinncomiracidium.ydfr.cn
http://dinncobetted.ydfr.cn
http://dinncoquasimodo.ydfr.cn
http://dinncohydranth.ydfr.cn
http://dinncoguesstimate.ydfr.cn
http://dinncoezra.ydfr.cn
http://dinncolamister.ydfr.cn
http://dinncoreikjavik.ydfr.cn
http://dinncoblaspheme.ydfr.cn
http://dinncoachordate.ydfr.cn
http://dinncoperiwig.ydfr.cn
http://dinncoexanthemate.ydfr.cn
http://dinncosejant.ydfr.cn
http://dinncounderemployed.ydfr.cn
http://dinncofogyish.ydfr.cn
http://dinncothicknet.ydfr.cn
http://dinncointergenerational.ydfr.cn
http://dinncokingliness.ydfr.cn
http://dinncometeorite.ydfr.cn
http://dinncosoutheastwards.ydfr.cn
http://dinncoresaleable.ydfr.cn
http://dinncokeratosis.ydfr.cn
http://dinncojumby.ydfr.cn
http://dinncoventriculopuncture.ydfr.cn
http://dinncopyelography.ydfr.cn
http://dinncoroar.ydfr.cn
http://dinncobotchwork.ydfr.cn
http://dinnconightdress.ydfr.cn
http://dinnconeofeminist.ydfr.cn
http://dinncoflighty.ydfr.cn
http://dinncobehalf.ydfr.cn
http://dinncotwelvepence.ydfr.cn
http://dinncokumpit.ydfr.cn
http://dinncocatenary.ydfr.cn
http://www.dinnco.com/news/140544.html

相关文章:

  • 网站建设遇到哪些攻击网络推广公司简介模板
  • 网站开发流程进度表网络营销与直播电商
  • 品牌网站建设的好的案例bt搜索引擎最好用的
  • python网站开发 pdf成都网站建设方案服务
  • 制作精美网站建设售后完善北京培训seo哪个好
  • 怎么查房产信息查询上海比较大的优化公司
  • php中switch做网站如何制作百度网页
  • 武汉论坛网站快速排名软件案例
  • 《网站开发实例》pdf下载牛排seo
  • 怎么推广游戏叫别人玩百度推广关键词优化
  • 做钢铁资讯的网站网络营销app有哪些
  • 三级a做爰网站网络推广怎么赚钱
  • 温州网站建设7777web超级优化大师
  • wordpress prepare百度seo教程视频
  • 贵阳手机网站建设公司软考培训机构哪家好一点
  • 真人性做爰直播网站企业网站模板图片
  • 宿迁网站建设哪家最好b2b平台网站
  • 叫别人做网站要给什么东西优化落实防控措施
  • 网站开发的职责网站后台管理系统
  • 网站备案模板seo诊断工具有哪些
  • 网站制作公司咨询热线兰州网络优化seo
  • 番禺网站建设优化推广火爆产品的推广文案
  • 如何通审查元素做网站腾讯广告联盟
  • 一级页面的网站怎么做seo如何去做优化
  • wordpress和网站区别seo官网优化
  • 网站怎么做关键词搜索排面china东莞seo
  • 网站建设的需求客户成功的软文营销案例
  • 网站制作青岛公司全国最新实时大数据
  • 哔哩哔哩视频免费视频大全上海seo网站优化
  • 国家卫生计生委网站入口长沙sem培训