Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3657130
  • 博文数量: 365
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2522
  • 用 户 组: 普通用户
  • 注册时间: 2019-10-28 13:40
文章分类

全部博文(365)

文章存档

2023年(8)

2022年(130)

2021年(155)

2020年(50)

2019年(22)

我的朋友

分类: Python/Ruby

2022-04-26 17:38:17

mulpicplus = "3"     #1 for normal,2 for 4pic plus,3 for 9pic plus and so on

        assert(int(mulpicplus)>=1)

        if mulpicplus == "1":

            pred = model(img,

                          augment=augment,

                          visualize=increment_path(save_dir / Path(path).stem, mkdir=True) if visualize else False)[0]

        else:

            xsz = img.shape[2]

            ysz = img.shape[3]

            mulpicplus = int(mulpicplus)

            x_smalloccur = int(xsz / mulpicplus * 1.2)

            y_smalloccur = int(ysz / mulpicplus * 1.2)

            for i in range(mulpicplus):

                x_startpoint = int(i * (xsz / mulpicplus))

                for j in range(mulpicplus):

                    y_startpoint = int(j * (ysz / mulpicplus))

                    x_real = min(x_startpoint + x_smalloccur, xsz)

                    y_real = min(y_startpoint + y_smalloccur, ysz)

                    if (x_real - x_startpoint) % 64 != 0:

                        x_real =外汇跟单gendan5.com x_real - (x_real-x_startpoint) % 64

                    if (y_real - y_startpoint) % 64 != 0:

                        y_real = y_real - (y_real - y_startpoint) % 64

                    dicsrc = img[:, :, x_startpoint:x_real,

                                                    y_startpoint:y_real]

                    pred_temp = model(dicsrc,

                                    augment=augment,

                                    visualize=increment_path(save_dir / Path(path).stem, mkdir=True) if visualize else False)[0]

                    pred_temp[..., 0] = pred_temp[..., 0] + y_startpoint

                    pred_temp[..., 1] = pred_temp[..., 1] + x_startpoint

                    if i==0 and j == 0:

                        pred = pred_temp

                    else:

                        pred = torch.cat([pred, pred_temp], dim=1)

        # Apply NMS

        pred = non_max_suppression(pred, conf_thres, iou_thres, classes, agnostic_nms, max_det=max_det)

阅读(1494) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~