当前位置:网站首页>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))
边栏推荐
- 安装mongodb数据库
- Deep clustering: joint optimization of depth representation learning and clustering
- 3531. Huffman tree
- Storage of dental stem cells (to be continued)
- QT console output in GUI applications- Console output in a Qt GUI app?
- 你不知道的互联网公司招聘黑话大全
- 开发者别错过!飞桨黑客马拉松第三期链桨赛道报名开启
- 360 Zhiyu released 7.0 new products to create an exclusive "unified digital workspace" for the party, government and army, and central and state-owned enterprises
- [SQL practice] a SQL statistics of epidemic distribution across the country
- ST表预处理时的数组证明
猜你喜欢
postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license
Dc-7 target
软件测试知识储备:关于「登录安全」的基础知识,你了解多少?
[SOC FPGA] custom IP PWM breathing lamp
Software testing knowledge reserve: how much do you know about the basic knowledge of "login security"?
3531. 哈夫曼树
【SQL实战】一条SQL统计全国各地疫情分布情况
Sequential storage of stacks
Jcmd of JVM command: multifunctional command line
软件测试的几个关键步骤,你需要知道
随机推荐
A very good JVM interview question article (74 questions and answers)
你不知道的互联网公司招聘黑话大全
Solve pod install error: FFI is an incompatible architecture
693. 行程排序
Laravel uses Tencent cloud cos5 full tutorial
从“跑分神器”到数据平台,鲁大师开启演进之路
【SQL实战】一条SQL统计全国各地疫情分布情况
那些自损八百的甲方要求
安装VMmare时候提示hyper-v / device defender 侧通道安全性
JMeter function assistant - random value, random string, fixed value random extraction
Qt多线程的多种方法之一 QThread
Peripheral driver library development notes 43: GPIO simulation SPI driver
Understand the deserialization principle of fastjson for generics
Change the original style of UI components
Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
cf:C. Column Swapping【排序 + 模擬】
rt-thread 中对 hardfault 的处理
tkinter窗口选择pcd文件并显示点云(open3d)
ST表预处理时的数组证明
Check Point:企业部署零信任网络(ZTNA)的核心要素