Code Monkey home page Code Monkey logo

yolov5_tensorrt's Introduction

yolov5_tensorrt

This is the implementation that supports the version 1.0 of yolov5s, yolov5m, yolov5l and yolov5x.
The Pytorch implementation of yolov5 version 1.0 is provided in this repos.
The latest ultralytics/yolov5 version 2.0 of https://github.com/ultralytics/yolov5 is not supported
You can see source code of yolov5s on https://github.com/wang-xinyu/tensorrtx/tree/master/yolov5
You can see Pytorch implementatuon of ultralytics/yolov5(version 1.0) on https://github.com/ultralytics/yolov5/releases/tag/v1.0

Test Environment

  1. GTX1080 / Ubuntu16.04 or GTX2080Ti / Ubuntu18.04
  2. cuda >= 10.0 , cudnn >= 7.0.0 , tensorrt7.0.0, nvinfer7.0.0, opencv3.3(I use opencv3.4)

How to Run

You should check the compile environment in the CMakeLists.txt for each folder(yolov5s,yolov5m,yolov5l,yolov5x).
Each folder has a readme inside, which explains how to run the models inside.
You can download pt files of ultralytics/yolov5(s,m,l,x)(version 1.0) on BaiduCloud, passwd:9cw1
Or you can download pt files of ultralytics/yolov5(s,m,l,x)(version 1.0) on https://github.com/ultralytics/yolov5/releases/tag/v1.0
Now, this repos only support yolov5 version 1.0.

Acknowledgments

Thanks to wang-xinyu for his great works and repos.

yolov5_tensorrt's People

Contributors

aipakchoi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

yolov5_tensorrt's Issues

大佬,yolov5m无法运行

我使用最新的yolov5m.pt转换成wts格式后,可以成功编译,但是无法生成引擎
出现了如下错误:

Loading weights: ./yolov5m.wts
yolov5-m2: ../yolov5-m2/common.hpp:128:std::map<std::__cxx11::basic_string<char>, nvinfer1::Weights> loadWeights(std::__cxx11::string): 假设 ‘input.is_open() && "Unable to load weight file."’ 失败。
程序异常结束。

我之前使用wangxinyu的yolov5s可以成功生成引擎,应该不是环境问题吧?
我对比了我们的运行环境,是一致的。
感谢您的帮助

yolov5x 序列化报错

./yolov5x -s
Loading weights: ../yolov5x.wts
[07/24/2020-15:40:23] [E] [TRT] Parameter check failed at: ../builder/Network.cpp::addScale::434, condition: shift.count > 0 ? (shift.values != nullptr) : (shift.values == nullptr)
yolov5x: /home/admin/Projects/tensorrtx/yolov5x/common.hpp:189: nvinfer1::IScaleLayer* addBatchNorm2d(nvinfer1::INetworkDefinition*, std::map<std::__cxx11::basic_string, nvinfer1::Weights>&, nvinfer1::ITensor&, std::__cxx11::string, float): Assertion `scale_1' failed.
Aborted (core dumped)

关于yolov5s编译的问题

[ 25%] Building NVCC (Device) object CMakeFiles/yololayer.dir/yololayer_generated_yololayer.cu.o
/home/yolov5_tensorrt/yolov5s/yololayer.h(103): warning: function "nvinfer1::IPluginV2Ext::configurePlugin(const nvinfer1::Dims *, int, const nvinfer1::Dims *, int, const nvinfer1::DataType *, const nvinfer1::DataType *, const __nv_bool *, const __nv_bool *, nvinfer1::PluginFormat, int)" is hidden by "nvinfer1::YoloLayerPlugin::configurePlugin" -- virtual function override intended?

/home/yolov5_tensorrt/yolov5s/yololayer.h(103): warning: function "nvinfer1::IPluginV2Ext::configurePlugin(const nvinfer1::Dims *, int, const nvinfer1::Dims *, int, const nvinfer1::DataType *, const nvinfer1::DataType *, const bool *, const bool *, nvinfer1::PluginFormat, int)" is hidden by "nvinfer1::YoloLayerPlugin::configurePlugin" -- virtual function override intended?

Scanning dependencies of target yololayer
[ 50%] Linking CXX shared library libyololayer.so
[ 50%] Built target yololayer
Scanning dependencies of target yolov5s
[ 75%] Building CXX object CMakeFiles/yolov5s.dir/yolov5s.cpp.o
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
from /usr/local/include/opencv2/core/base.hpp:55,
from /usr/local/include/opencv2/core.hpp:54,
from /usr/local/include/opencv2/opencv.hpp:52,
from /home/yolov5_tensorrt/yolov5s/common.hpp:8,
from /home/yolov5_tensorrt/yolov5s/yolov5s.cpp:5:
/usr/include/c++/4.8.2/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Yolo::Detection*, std::vectorYolo::Detection >; _Tp = Yolo::Detection; _Compare = bool ()(Yolo::Detection&, Yolo::Detection&)]':
/usr/include/c++/4.8.2/bits/stl_algo.h:2296:78: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Yolo::Detection
, std::vectorYolo::Detection >; _Compare = bool ()(Yolo::Detection&, Yolo::Detection&)]'
/usr/include/c++/4.8.2/bits/stl_algo.h:2337:62: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Yolo::Detection
, std::vectorYolo::Detection >; _Size = long int; _Compare = bool ()(Yolo::Detection&, Yolo::Detection&)]'
/usr/include/c++/4.8.2/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<Yolo::Detection
, std::vectorYolo::Detection >; _Compare = bool ()(Yolo::Detection&, Yolo::Detection&)]'
/home/yolov5_tensorrt/yolov5s/common.hpp:106:48: required from here
/usr/include/c++/4.8.2/bits/stl_algo.h:2263:35: error: invalid initialization of reference of type 'Yolo::Detection&' from expression of type 'const Yolo::Detection'
while (__comp(
__first, __pivot))
^
compilation terminated due to -Wfatal-errors.
make[2]: *** [CMakeFiles/yolov5s.dir/yolov5s.cpp.o] Error 1
make[1]: *** [CMakeFiles/yolov5s.dir/all] Error 2
make: *** [all] Error 2

yolov5s v1.0 序列化报错

我使用yolov5 v1.0训练了yolov5s模型,然后进行序列化,得到以下信息:

Loading weights: ../yolov5s.wts
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: kernel weights has count 2304 but 32640 was expected
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: count of 2304 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: kernel weights has count 2304 but 32640 was expected
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: count of 2304 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: kernel weights has count 2304 but 32640 was expected
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: count of 2304 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: kernel weights has count 2304 but 32640 was expected
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: count of 2304 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640
Building engine, please wait for a while...
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: kernel weights has count 2304 but 32640 was expected
[07/31/2020-11:37:13] [E] [TRT] (Unnamed Layer* 173) [Convolution]: count of 2304 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 255 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 255 / 1 = 32640
[07/31/2020-11:37:13] [E] [TRT] Could not compute dimensions for (Unnamed Layer* 173) [Convolution]_output, because the network is not valid.
[07/31/2020-11:37:13] [E] [TRT] Network validation failed.
Build engine successfully!
yolov5s: yolov5_tensorrt/yolov5s/yolov5s.cpp:170: void APIToModel(unsigned int, nvinfer1::IHostMemory**): Assertion `engine != nullptr' failed.
已放弃 (核心已转储)

请帮我看一下大概是什么问题,谢谢了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.