当前位置:网站首页>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))
边栏推荐
- Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
- 蚂蚁庄园安全头盔 7.8蚂蚁庄园答案
- Subghz, lorawan, Nb IOT, Internet of things
- Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
- Detailed explanation of platform device driver architecture in driver development
- CMD permanently delete specified folders and files
- Cloud acceleration helps you effectively solve attack problems!
- PTA ladder game exercise set l2-004 search tree judgment
- Change the original style of UI components
- Oracle迁移中关于大容量表使用数据泵(expdp、impdp)导出导入容易出现的问题和注意事项
猜你喜欢

Financial risk control practice - decision tree rule mining template

Introduction to the extension implementation of SAP Spartacus checkout process

Laravel uses Tencent cloud cos5 full tutorial

Ctfshow-- common posture

Red hat install kernel header file

Dc-7 target

【GNN】图解GNN: A gentle introduction(含视频)

On the discrimination of "fake death" state of STC single chip microcomputer

DC-7靶机

yarn入门(一篇就够了)
随机推荐
Rk3399 platform development series explanation (WiFi) 5.52. Introduction to WiFi framework composition
Check point: the core element for enterprises to deploy zero trust network (ztna)
关于STC单片机“假死”状态的判别
Red hat install kernel header file
Swagger3 configuration
Bypass open_ basedir
Laravel uses Tencent cloud cos5 full tutorial
@Detailed differences between pathvariable and @requestparam
那些自损八百的甲方要求
搞懂fastjson 对泛型的反序列化原理
Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
The boss always asks me about my progress. Don't you trust me? (what do you think)
【SQL实战】一条SQL统计全国各地疫情分布情况
开发者别错过!飞桨黑客马拉松第三期链桨赛道报名开启
Jstack of JVM command: print thread snapshots in JVM
JVM monitoring and diagnostic tools - command line
当我们谈论不可变基础设施时,我们在谈论什么
New Year Fireworks code plus copy, are you sure you don't want to have a look
基于FPGA的VGA协议实现
基于ADAU1452的DSP及DAC音频失真分析