Mobilenet-YOLO-Pytorch icon indicating copy to clipboard operation
Mobilenet-YOLO-Pytorch copied to clipboard

problem about the Image processing time(600ms)

Open cucdengjunli opened this issue 3 years ago • 3 comments

Dear Eric Liu, I have tested the processing time on your code. using "model_best.pth.tar" you listed on your "readme", one image(the image you offered on "images") processing time is 600ms , it is too long compare to Yolo-Fastest(20ms)[https://github.com/dog-qiuqiu/Yolo-Fastest]. I wonder if it is a normal time result, if not, May I ask you what error I make?

`def inference_image(model, original_image,device): # Transforms transform_test = transforms.Compose([ transforms.Resize(size=(416,416), interpolation=2), transforms.ToTensor(), transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)), ]) # Transform image = transform_test(original_image)

# Move to default device
image = image.to(device)

start_3 = datetime.utcnow()
print("model函数之前前", start_3)

detections = model(image.unsqueeze(0))  # (N, num_defaultBoxes, 4), (N, num_defaultBoxes, n_classes)

end_3 = datetime.utcnow()
print("model函数之后后", end_3)

c3 = (end_3 - start_3)
print("model经过多少秒", c3)
print("model经过多少秒(不含毫秒)", c3.seconds)
print("model经过多少毫秒c.microseconds", c3.microseconds)

Uploading 捕获.PNG… `

微信图片_20210706140541

cucdengjunli avatar Jul 06 '21 06:07 cucdengjunli

This is my code for estimating time

def inference_image(model, original_image,device):
    # Transforms
    transform_test = transforms.Compose([
        transforms.Resize(size=(352,352), interpolation=2),
        transforms.ToTensor(),
        transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
    ])
    # Transform
    image = transform_test(original_image)
    image = image.to(device)
    # Move to default device  
    start_3 = datetime.now().timestamp()
    print("model函数之前前", start_3)          
    detections = model(image.unsqueeze(0))  # (N, num_defaultBoxes, 4), (N, num_defaultBoxes, n_classes)
    end_3 =datetime.now().timestamp()
    print("model函数之后后", end_3)

    c3 = (end_3 - start_3)
    print("model经过多少秒", c3)
    print("model经过多少毫秒", c3*1000)

    return detections

in line , the result was

model函数之前前 1625622913.572254
model函数之后后 1625622913.588143
model经过多少秒 0.01588916778564453
model经过多少毫秒 15.889167785644531

And also , I updated the inference resolution ,

transforms.Resize(size=(352,352), interpolation=2),

eric612 avatar Jul 07 '21 01:07 eric612

Dear Eric Liu, I use your code, but my result is still >=600ms, this is my computer configuration,could you please tell me why?thank you。 实验室台式机性能

cucdengjunli avatar Jul 12 '21 12:07 cucdengjunli

My device was GTX1080 Ti , your result was too strange . Did your gpu device was enabled ?

eric612 avatar Jul 13 '21 06:07 eric612