brandleyzhou / DIFFNet

[BMVC 2021] ''Self-Supervised Monocular Depth Estimation with Internal Feature Fusion''
109 stars 21 forks source link

About model's FPS #13

Closed big-chan closed 2 years ago

big-chan commented 2 years ago

Hello Thank you for your good work!!

I'm calculating the DIFFNet's FPS in RTX2080ti to fairly compare our works. But the DIFFNet and monodepth2 's fps are so different from those reported in your paper. Can I get your code to calculate the fps, please?

I measured the fps with the following code.

import torch
import networks
en = networks.test_hr_encoder.hrnet18(False)
en.num_ch_enc = [ 64, 18, 36, 72, 144 ]
de= networks.HRDepthDecoder(en.num_ch_enc, [0])
# depth_net=DepthResNet(version="101pt")
=
device = torch.device('cuda')
en.to(device)
en.eval()
de.to(device)
de.eval()
optimal_batch_size=1
dummy_input = torch.randn(optimal_batch_size, 3,192,640, dtype=torch.float).to(device)
repetitions=10000
total_time = 0
print("start calculate")
with torch.no_grad():
      for rep in range(repetitions):
             starter, ender = torch.cuda.Event(enable_timing=True), torch.cuda.Event(enable_timing=True)
             starter.record()
             _ = de(en(dummy_input))
             ender.record()
             torch.cuda.synchronize()
             curr_time = starter.elapsed_time(ender)/1000
             if rep!=0:
                 total_time += curr_time
repetitions=repetitions-1
print(total_time)
Throughput = (repetitions*optimal_batch_size)/total_time
print('Final FPS:',Throughput,' total_time:',total_time)
print("weight num: ",sum(p.numel() for p in en.parameters())+sum(p.numel() for p in de.parameters()))

And the following results were obtained for each models.

Model FPS
DIFFNet 34.92
Monodepth2 282.25
brandleyzhou commented 2 years ago

You can refer to 122--149 lines in eval_depth.py. I manually calculate the FPS (FPS = total test images / total time )

big-chan commented 2 years ago

Thank you to reply!.