当前位置:网站首页>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))
边栏推荐
- Experience of Niuke SQL
- JVM命令之 jstat:查看JVM统计信息
- [FPGA tutorial case 14] design and implementation of FIR filter based on vivado core
- 苹果cms V10模板/MXone Pro自适应影视电影网站模板
- Cf:c. column swapping [sort + simulate]
- SAP Spartacus checkout 流程的扩展(extend)实现介绍
- win系统下安装redis以及windows扩展方法
- Change the original style of UI components
- JVM监控及诊断工具-命令行篇
- Apple CMS V10 template /mxone Pro adaptive film and television website template
猜你喜欢

Subghz, lorawan, Nb IOT, Internet of things

postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license

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

Laravel uses Tencent cloud cos5 full tutorial

搞懂fastjson 对泛型的反序列化原理

rt-thread 中对 hardfault 的处理

JVM命令之 jstat:查看JVM统计信息

jvm命令之 jcmd:多功能命令行

当我们谈论不可变基础设施时,我们在谈论什么

【GNN】图解GNN: A gentle introduction(含视频)
随机推荐
【GNN】图解GNN: A gentle introduction(含视频)
Red hat install kernel header file
Introduction to yarn (one article is enough)
Check Point:企业部署零信任网络(ZTNA)的核心要素
进程间通信之共享内存
JVM命令之 jinfo:实时查看和修改JVM配置参数
C. colonne Swapping [tri + Simulation]
How to keep accounts of expenses in life
On the discrimination of "fake death" state of STC single chip microcomputer
[FPGA tutorial case 13] design and implementation of CIC filter based on vivado core
Check point: the core element for enterprises to deploy zero trust network (ztna)
Subghz, lorawan, Nb IOT, Internet of things
如果不知道这4种缓存模式,敢说懂缓存吗?
测试开发基础,教你做一个完整功能的Web平台之环境准备
为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾
Jcmd of JVM command: multifunctional command line
Laravel uses Tencent cloud cos5 full tutorial
职场经历反馈给初入职场的程序员
软件测试知识储备:关于「登录安全」的基础知识,你了解多少?
JVM命令之 jstat:查看JVM統計信息