deep_sort_pytorch
deep_sort_pytorch copied to clipboard
timecost of image preprocessing(incluse resize) in detector.py is high
original code :
img = ori_img.astype(np.float)/255.
img = cv2.resize(img, self.size)
img = torch.from_numpy(img).float().permute(2,0,1).unsqueeze(0)
img = img.to(self.device)
with torch.no_grad():
out_boxes = self.net(img)
I suggest using:
from PIL import Image
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
from torch.autograd import Variable
img = Image.fromarray(ori_img)
img_transforms=transforms.Compose([transforms.Resize((self.size)),
transforms.ToTensor(),
])
Tensor = torch.cuda.FloatTensor
image_tensor = img_transforms(img).float()
image_tensor = image_tensor.unsqueeze_(0)
img = Variable(image_tensor.type(Tensor))
with torch.no_grad():
out_boxes = self.net(img)
the test speed will be faster :
resized = cv2.resize(ori_img, self.size, interpolation=cv2.INTER_LINEAR) img_in = np.transpose(resized, (2, 0, 1)).astype(np.float32) img_in = np.expand_dims(img_in, axis=0) img_in /= 255.0 img_in = np.ascontiguousarray(img_in) Tensor = torch.cuda.FloatTensor img = Variable(torch.tensor(img_in).to(self.device))
wow, It works! My detector speed increased by 20%! excellent! Another question, what's your utilization rate of the GPU? Mine is only 1%, what can I do to improve it? Or is there anything wrong during my installation?
sorry , I don't know much about it
try to use this command :watch -n0.05 nvidia-smi
to watch your device, it changes every time, hope it works
can you tell me your fps? my fps is just 8 or 9.
can you tell me your fps? my fps is just 8 or 9.
mine is just 9-11, also not very high.Maybe that is because my GPU is poor
my gpu 1080ti. how about yours?
mine is 1050, but the number of the object in my video is small, about 25--35. What about yours?
much the same! I don't know why my fps is so low