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
- RepVGG部署模型 HOT 1
- 【已解决】No module named 'utils.history' HOT 1
- 测试单张图片时报错: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU. HOT 2
- loss
- 模型保存
- 细粒度分类算法 HOT 2
- 制作数据集信息文件时,发生ValueError:too mach values to unpack(expected 2) HOT 2
- 加载权重文件失败 HOT 1
- 训练时数据数目与数据集的数目不匹配 HOT 1
- upup,为啥只有训练loss和验证acc HOT 4
- 数据集问题 HOT 1
- 能否批量输出类激活图 HOT 2
- 是否支持训练视频分类?
- 怎么用训练好的模型批量预测呀 HOT 4
- 作者您好,请教关于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
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.