if int(con_neg[con_neg >= 0.8].size(0)) > 0: test_neg = torch.sigmoid(conf_preds[:, :, 0]) test_neg[pos_mask]=0 for x in range(images.size(0)): if test_neg[x][test_neg[x]>0].size(0)>0: # tmp_loc=loc_preds[x].cpu().data # tmp_conf= test_neg[x].cpu().data tmp_loc=loc_preds[x] tmp_conf= test_neg[x] self.data_encoder.test_encode(tmp_loc,tmp_conf,images[x].cpu())
encodeel.py:
# coding:utf-8 import torch import math import itertools import cv2 import numpy as np from skimage import img_as_ubyte class DataEncoder: # compute default boxes def __init__(self,use_gpu,is_train,image_size): scale = 720. anchors = np.array([[50, 20], [20, 50], [40, 40]]) anchors = anchors / 384 # 14007 sizes = [s / scale for s in (45, 48, 48)] aspect_ratios = ((1.2, 1.45, 1.7), (1,), (1,)) # 框