当前位置:网站首页>Calculation model FPS
Calculation model FPS
2022-07-07 06:18:00 【ViatorSun】
Whether it is image classification or , object detection / Instance segmentation , Detection speed is an important indicator .
Calculation model FPS The process :
Just add one before and after the model runs time Just record the time , Then calculate the model through the time difference 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)))
The complete code can be referred to as follows
import time
import torch
import numpy as np
net = build_model
net.eval()
# x Is the size of the input picture
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))
边栏推荐
- Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
- Storage of dental stem cells (to be continued)
- [SOC FPGA] custom IP PWM breathing lamp
- JVM命令之 jstat:查看JVM统计信息
- vim映射大K
- Check point: the core element for enterprises to deploy zero trust network (ztna)
- 话说SQLyog欺骗了我!
- Apple CMS V10 template /mxone Pro adaptive film and television website template
- MFC BMP sets the resolution of bitmap, DPI is 600 points, and gdiplus generates labels
- From "running distractor" to data platform, Master Lu started the road of evolution
猜你喜欢
[cloud native] what is the microservice architecture?
JVM命令之 jstat:查看JVM統計信息
POI excel export, one of my template methods
JVM命令之 jstack:打印JVM中线程快照
How to set up in touch designer 2022 to solve the problem that leap motion is not recognized?
话说SQLyog欺骗了我!
一个简单的代数问题的求解
The boss always asks me about my progress. Don't you trust me? (what do you think)
Vscode for code completion
【SQL实战】一条SQL统计全国各地疫情分布情况
随机推荐
Rk3399 platform development series explanation (WiFi) 5.52. Introduction to WiFi framework composition
绕过open_basedir
Sequential storage of stacks
JVM监控及诊断工具-命令行篇
laravel 使用腾讯云 COS5全教程
【SQL实战】一条SQL统计全国各地疫情分布情况
Jmeter自带函数不够用?不如自己动手开发一个
VScode进行代码补全
云加速,帮助您有效解决攻击问题!
[SQL practice] a SQL statistics of epidemic distribution across the country
Jstat pour la commande JVM: voir les statistiques JVM
Introduction to yarn (one article is enough)
从“跑分神器”到数据平台,鲁大师开启演进之路
[FPGA] EEPROM based on I2C
3531. 哈夫曼树
[FPGA tutorial case 14] design and implementation of FIR filter based on vivado core
Value range of various datetimes in SQL Server 2008
Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
win系统下安装redis以及windows扩展方法