Face Transformer Table I Query
khawar-islam opened this issue · 4 comments
khawar-islam commented
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
zhongyy commented
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)
khawar-islam commented
Thank you @zhongyy
khawar-islam commented
@zhongyy Would it be possible for you to check this batch_device = batch.to(device)
code again. I am getting errors in this line.
zhongyy commented
@khawar512 The code comes from "test_forward()" of "https://github.com/zhongyy/Face-Transformer/blob/main/util/utils.py", maybe you can try "https://github.com/zhongyy/Face-Transformer/blob/main/test_forward.py".