Comments (4)
这个问题以前有人私信问过我,当时手把手教他改了,你只需要读取视频为图片序列后再逐一检测和显示就行,如果需要的话我还是上传一个视频检测文件吧
from awesome-backbones.
我已经读取了视频,并传给了inference_model,但出现了报错,找不到解决方法。
`import time
from argparse import ArgumentParser
import os
import sys
import cv2
sys.path.insert(0, os.getcwd())
import torch
from utils.inference import inference_model, init_model, show_result_pyplot
from utils.train_utils import get_info, file2dict
from models.build import BuildNet
def main():
video = '/home/sw/PycharmProjects/data/2021115163527.mp4'
config = '/home/sw/PycharmProjects/Classification/Awesome-Backbones-0.6.0/models/shufflenet/shufflenet_v2.py'
device = 'cuda:0'
save_path = './log'
classes_map = '../datas/annotations.txt'
classes_names, _ = get_info(classes_map)
# build the model from a config file and a checkpoint file
model_cfg, train_pipeline, val_pipeline, data_cfg, lr_config, optimizer_cfg = file2dict(config)
if device is not None:
device = torch.device(device)
else:
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = BuildNet(model_cfg)
model = init_model(model, data_cfg, device=device, mode='eval')
cap=cv2.VideoCapture(video)
while True:
flag, frame = cap.read()
if not flag:
break
t1 = time.time()
# test a single image
frame = torch.from_numpy(frame)
result = inference_model(model, frame, val_pipeline, classes_names)
show_result_pyplot(model, img, result, out_file=save_path)
if name == 'main':
main()`
from awesome-backbones.
已更新,请拉取最新版本,或者单独下载tools/video_test.py以及更新utils/inference.py,如果解决了你的问题还麻烦在这里给个回复哈
from awesome-backbones.
您好,已经可以推理视频了,非常感谢。
from awesome-backbones.
Related Issues (20)
- 权重大小不匹配 HOT 2
- evaluation 进行模型评估时,数据集从何而来 HOT 1
- 该程序想要在pycharm中运行该怎么使用 HOT 1
- 如果用mvit,t2t_vit,visiontransformer三个算法分别得到三个模型,如何用adaboost将他们集成呢,这是可行的吗
- 调用evaluation脚本时每次准确率结果会有细微的差别 HOT 9
- mobileNet演示就报错TT,请问这个问题怎么解决啊?
- mobileNet演示项目问题? HOT 1
- 主要组成部分 HOT 1
- t2t_vit_19模型主要包含哪些部分 HOT 1
- 作者您好,请教关于mobilenetv3 small的输出维度问题 HOT 1
- Loss损失函数问题 HOT 1
- opencv_python、opencv_contrib_python、opencv-python-headless 的版本用的多少啊,总是说我的版本不匹配 HOT 1
- 1.电脑有两个GPU 0和1,如何改代码使它使用GPU1呀。2.CUDA out of memory这个问题是因为什么呀 HOT 1
- 请问这个报错:AttributeError: 'EfficientFormerClsHead' object has no attribute 'post_process',没有post_process()方法? HOT 6
- 怎么导出.wts HOT 1
- 1
- 怎么改变批量预测的结果字体的大小 HOT 7
- 为什么训练时,精确度能有90%多,但模型评估时,预测结果准确率很低,甚至有时会出现预测结果全为一类(我预测的是二分类) HOT 1
- 后续会加入一些新的模型吗比如squeezenet、xception
- 加入新的主干运行后出现Initialize the weights. Traceback (most recent call last): File "tools/train.py", line 171, in <module> main() File "tools/train.py", line 136, in main max_iters = data_cfg.get('train').get('epoches')*len(train_loader), TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'的问题怎么解决 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awesome-backbones.