当前位置:网站首页>计算模型 FPS
计算模型 FPS
2022-07-07 01:26:00 【ViatorSun】
无论是图像分类也好,目标检测/实例分割也罢,检测速度都是一个重要指标。
计算模型FPS过程:
只需要在模型运行前后各添加一个 time记录时间即可,然后通过时间差计算出模型 FPS
start = time.time()
with torch.no_grad():
seg_result = model.forward(img, target)
img_show = show_result_ins(imgpath, seg_result)
end = time.time()
t_all = end - start
# print("spend time: ", t_all ,"s")
print('average time:{:.02f} s'.format(np.mean(t_all) / 1))
print('average FPS :{:.02f} fps'.format(1 / np.mean(t_all)))
完整代码可以参考如下
import time
import torch
import numpy as np
net = build_model
net.eval()
# x是输入图片的大小
x = torch.zeros((1,3,H,W)).cuda()
t_all = []
for i in range(100):
t1 = time.time()
y = net(x)
t2 = time.time()
t_all.append(t2 - t1)
print('average time:', np.mean(t_all) / 1)
print('average fps:',1 / np.mean(t_all))
print('fastest time:', min(t_all) / 1)
print('fastest fps:',1 / min(t_all))
print('slowest time:', max(t_all) / 1)
print('slowest fps:',1 / max(t_all))
边栏推荐
猜你喜欢

如何在Touch Designer 2022版中设置解决Leap Motion不识别的问题?

Forkjoin is the most comprehensive and detailed explanation (from principle design to use diagram)

cf:C. Column Swapping【排序 + 模拟】

Jstat pour la commande JVM: voir les statistiques JVM

JVM命令之 jstack:打印JVM中线程快照
![Cf:c. column swapping [sort + simulate]](/img/0e/64d17980d3ec0051cdfb5fdb34e119.png)
Cf:c. column swapping [sort + simulate]

PTA ladder game exercise set l2-004 search tree judgment

Say sqlyog deceived me!

Add salt and pepper noise or Gaussian noise to the picture

外设驱动库开发笔记43:GPIO模拟SPI驱动
随机推荐
EMMC print cqhci: timeout for tag 10 prompt analysis and solution
Randomly generate session_ id
Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)
当我们谈论不可变基础设施时,我们在谈论什么
Things about data storage 2
Storage of dental stem cells (to be continued)
@Detailed differences between pathvariable and @requestparam
Opensergo is about to release v1alpha1, which will enrich the service governance capabilities of the full link heterogeneous architecture
Flask1.1.4 Werkzeug1.0.1 源码分析:启动流程
可极大提升编程思想与能力的书有哪些?
k8s运行oracle
go-microservice-simple(2) go-Probuffer
PTA 天梯赛练习题集 L2-003 月饼 测试点2,测试点3分析
职场经历反馈给初入职场的程序员
Detailed explanation of platform device driver architecture in driver development
Rk3399 platform development series explanation (interruption) 13.10, workqueue work queue
3428. 放苹果
Bypass open_ basedir
Change the original style of UI components
Mac version PHP installed Xdebug environment (M1 version)