zhongyy/Face-Transformer

Face Transformer Table I Query

khawar-islam opened this issue · 4 comments

I would like to ask one question about the table I in your Face Transformer paper.
How you calculate the speed of Img/Sec in Table I?

I am using the below library but I have no idea how to calculate inference speed?
https://github.com/sovrasov/flops-counter.pytorch

You can record the inference time of n images and then calculate the mean value.

    import time

    backbone = backbone.to(device)
    backbone.eval() # switch to evaluation mode
    forward_time = 0
    carray = data_set[0]
    idx = 0
    with torch.no_grad():
            while idx < 2000:
                batch = carray[idx:idx + 1]
                batch_device = batch.to(device)
                last_time = time.time()
                backbone(batch_device)
                forward_time += time.time() - last_time
    print("forward_time", 2000, forward_time, 2000/forward_time)

Thank you @zhongyy

@zhongyy Would it be possible for you to check this batch_device = batch.to(device) code again. I am getting errors in this line.