当前位置:网站首页>计算模型 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))
边栏推荐
- Flask1.1.4 Werkzeug1.0.1 源碼分析:啟動流程
- 当我们谈论不可变基础设施时,我们在谈论什么
- SAP ABAP BDC (batch data communication) -018
- Find duplicate email addresses
- JVM监控及诊断工具-命令行篇
- JVM monitoring and diagnostic tools - command line
- Chain storage of stack
- VScode进行代码补全
- [solved] record an error in easyexcel [when reading the XLS file, no error will be reported when reading the whole table, and an error will be reported when reading the specified sheet name]
- 一名普通学生的大一总结【不知我等是愚是狂,唯知一路向前奔驰】
猜你喜欢
@Detailed differences between pathvariable and @requestparam
[SQL practice] a SQL statistics of epidemic distribution across the country
Reading notes of Clickhouse principle analysis and Application Practice (6)
Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
laravel 使用腾讯云 COS5全教程
[daily training -- Tencent selected 50] 235 Nearest common ancestor of binary search tree
Rk3399 platform development series explanation (WiFi) 5.52. Introduction to WiFi framework composition
jvm命令之 jcmd:多功能命令行
Red hat install kernel header file
3531. 哈夫曼树
随机推荐
PTA TIANTI game exercise set l2-003 moon cake test point 2, test point 3 Analysis
Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
jmeter 函数助手 — — 随机值、随机字符串、 固定值随机提取
@pathvariable 和 @Requestparam的详细区别
What EDA companies are there in China?
ML之shap:基于adult人口普查收入二分类预测数据集(预测年收入是否超过50k)利用shap决策图结合LightGBM模型实现异常值检测案例之详细攻略
【GNN】图解GNN: A gentle introduction(含视频)
PowerPivot——DAX(函数)
Deep clustering: joint optimization of depth representation learning and clustering
Input of native applet switches between text and password types
[SQL practice] a SQL statistics of epidemic distribution across the country
Subghz, lorawan, Nb IOT, Internet of things
Jstat of JVM command: View JVM statistics
Swagger3 configuration
苹果cms V10模板/MXone Pro自适应影视电影网站模板
搞懂fastjson 对泛型的反序列化原理
那些自损八百的甲方要求
The solution of a simple algebraic problem
SubGHz, LoRaWAN, NB-IoT, 物联网
[daily training -- Tencent selected 50] 235 Nearest common ancestor of binary search tree