Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to speed up inference and compare features ? #13

Open
MyraBaba opened this issue Jul 6, 2023 · 1 comment
Open

Is it possible to speed up inference and compare features ? #13

MyraBaba opened this issue Jul 6, 2023 · 1 comment

Comments

@MyraBaba
Copy link

MyraBaba commented Jul 6, 2023

Hi

I have 2080RTX Ti and the below inference ~tooks 0,019 seconds after warmup . ~ 40 - 50 inference per second. Its look slow.
How I can make it faster ? Is it due to model size ?

Also

@torch.no_grad()
def get_feature(img, model, device, normalize=False):
    input = val_transforms(img).unsqueeze(0)
    input = input.to(device)
                                                                                                       29,1          Top
    input = val_transforms(img).unsqueeze(0)
    input = input.to(device)
    output, _ = model(input)
    if normalize:
        output = F.normalize(output)
    return output

if device:
    if torch.cuda.device_count() > 1:
        print('Using {} GPUs for inference'.format(torch.cuda.device_count()))
    model = nn.DataParallel(model)
    model.to(device)

model.eval()

 elapsed_time = next(timer_gen)

    feature1 = get_feature(img1, model, device, normalize=True)
    elapsed_time = next(timer_gen) - elapsed_time
    print(elapsed_time)
@cwhgn
Copy link
Collaborator

cwhgn commented Jul 11, 2023

We test SOLIDER on person re-identification task based on the code of TransReID. Currently, we do not pay much attention on the inference speed. You may refer to TransReID to find whether they have some teches to speed up your code. FYI, a small model size or a small input image size would be a possible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants