当前位置:网站首页>计算模型 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))
边栏推荐
- C note 13
- 牙齿干细胞的存储问题(未完待续)
- 云加速,帮助您有效解决攻击问题!
- Ten stages of becoming a Senior IC Design Engineer. What stage are you in now?
- Cloud acceleration helps you effectively solve attack problems!
- Web authentication API compatible version information
- Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
- Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)
- CMD permanently delete specified folders and files
- Understand the deserialization principle of fastjson for generics
猜你喜欢
随机推荐
DC-7靶机
Add salt and pepper noise or Gaussian noise to the picture
Sequential storage of stacks
Rk3399 platform development series explanation (WiFi) 5.52. Introduction to WiFi framework composition
Red hat install kernel header file
苹果cms V10模板/MXone Pro自适应影视电影网站模板
404 not found service cannot be reached in SAP WebService test
CTFshow--常用姿势
Convert numbers to string strings (to_string()) convert strings to int sharp tools stoi();
Digital IC interview summary (interview experience sharing of large manufacturers)
@pathvariable 和 @Requestparam的详细区别
Flask1.1.4 Werkzeug1.0.1 源碼分析:啟動流程
驱动开发中platform设备驱动架构详解
3531. 哈夫曼树
Rk3399 platform development series explanation (interruption) 13.10, workqueue work queue
QT console output in GUI applications- Console output in a Qt GUI app?
jvm命令之 jcmd:多功能命令行
那些自损八百的甲方要求
PTA 天梯赛练习题集 L2-004 搜索树判断
测试开发基础,教你做一个完整功能的Web平台之环境准备









