当前位置:网站首页>计算模型 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))
边栏推荐
- Jstat of JVM command: View JVM statistics
- yarn入门(一篇就够了)
- 原生小程序 之 input切換 text與password類型
- 3428. 放苹果
- go-microservice-simple(2) go-Probuffer
- The solution of a simple algebraic problem
- Web authentication API compatible version information
- 3531. 哈夫曼树
- Data storage 3
- Jinfo of JVM command: view and modify JVM configuration parameters in real time
猜你喜欢
Loss function and positive and negative sample allocation in target detection: retinanet and focal loss
CTFshow--常用姿势
10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
Digital IC interview summary (interview experience sharing of large manufacturers)
JVM命令之- jmap:导出内存映像文件&内存使用情况
If you don't know these four caching modes, dare you say you understand caching?
Peripheral driver library development notes 43: GPIO simulation SPI driver
Cf:c. column swapping [sort + simulate]
高并发大流量秒杀方案思路
ML's shap: Based on the adult census income binary prediction data set (whether the predicted annual income exceeds 50K), use the shap decision diagram combined with the lightgbm model to realize the
随机推荐
Introduction to yarn (one article is enough)
[FPGA tutorial case 13] design and implementation of CIC filter based on vivado core
Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
职场经历反馈给初入职场的程序员
牙齿干细胞的存储问题(未完待续)
PTA ladder game exercise set l2-004 search tree judgment
高并发大流量秒杀方案思路
从“跑分神器”到数据平台,鲁大师开启演进之路
New Year Fireworks code plus copy, are you sure you don't want to have a look
Say sqlyog deceived me!
Jcmd of JVM command: multifunctional command line
jmeter 函数助手 — — 随机值、随机字符串、 固定值随机提取
How to improve website weight
Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
【SQL实战】一条SQL统计全国各地疫情分布情况
Flask1.1.4 werkzeug1.0.1 source code analysis: start the process
JVM命令之 jinfo:实时查看和修改JVM配置参数
10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
PTA TIANTI game exercise set l2-003 moon cake test point 2, test point 3 Analysis
Bypass open_ basedir