当前位置:网站首页>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))
边栏推荐
猜你喜欢

PTA ladder game exercise set l2-004 search tree judgment

软件测试知识储备:关于「登录安全」的基础知识,你了解多少?

进程间通信之共享内存

JVM命令之 jstat:查看JVM統計信息

JMeter's own functions are not enough? Why don't you develop one yourself

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

安装VMmare时候提示hyper-v / device defender 侧通道安全性

JVM command - jmap: export memory image file & memory usage

When we talk about immutable infrastructure, what are we talking about

SubGHz, LoRaWAN, NB-IoT, 物联网
随机推荐
Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
yarn入门(一篇就够了)
Sequential storage of stacks
QT console output in GUI applications- Console output in a Qt GUI app?
每秒10W次分词搜索,产品经理又提了一个需求!!!(收藏)
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
@pathvariable 和 @Requestparam的详细区别
Jinfo of JVM command: view and modify JVM configuration parameters in real time
How to set up in touch designer 2022 to solve the problem that leap motion is not recognized?
Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
693. 行程排序
win系统下安装redis以及windows扩展方法
安装mongodb数据库
C. colonne Swapping [tri + Simulation]
3428. 放苹果
Peripheral driver library development notes 43: GPIO simulation SPI driver
Dc-7 target
VScode进行代码补全
「解析」FocalLoss 解决数据不平衡问题
ML之shap:基于adult人口普查收入二分类预测数据集(预测年收入是否超过50k)利用shap决策图结合LightGBM模型实现异常值检测案例之详细攻略