-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Yolov5 classification model support #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@xiang-wuu Awesome, looking forward to your implementation. |
@xiang-wuu Hi, for classification model, can you write a separate .cpp file with main() function, and build another executable file? That will simplify the logic. |
…l alongwith existing detection model.
As the p6 scale models are not provided officially for Yolov5 classification models, so this can be done afterwards once the support is added. The normal scale models are working fine. |
…, hence hardcoded value provided to support all model varients
Evaluation Metrics
As per the last subtask, the model is been inferred separately using PyTorch and TRT over 50K validation dataset from imagenet, also the time complexity is averaged over 5K dry runs for both model implementations. The slight reduction in accuracy numbers of TRT model could possibly caused due to pre-processing or post-processing implementations. |
@wang-xinyu Hi, I appreciate your implementation. In C++, how do I display className and prob after the infer? In the Python file, there is an example, but I haven't seen it in the C++ file. Should I change these lines to: `for (int b = 0; b < fcount; b++) { }` To: }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot. I left few comments.
de-serialization is not handled in the CPP code, it can be easily implemented from the python infer script. |
@wang-xinyu 根据您的建议,所有更改都已完成 |
@xiang-wuu 我的意思是,不要修改yolov5.cpp和yolov5_trt.py这两个文件,现在PR里面包含了这两个文件的一点改动。 |
@wang-xinyu both the files |
@xiang-wuu Even format differences, can you revert them? Some lines don't need line-break, but line-breaks are applied. Especially in yolov5_trt.py. |
@wang-xinyu as you mention to revert the format changes in |
@xiang-wuu Can you please download the yolov5_trt.py from master branch and overwrite it to your current yolov5_trt.py? That will be easier. No need to consider the git commit state. |
@wang-xinyu Reverted back to prior commit. |
@xiang-wuu Thanks. |
@xiang-wuu So you are using v6.2, right? Have you tested the v6.2 detection model with your branch? |
@wang-xinyu Hi, I'd like to print the classification result in C++ but the result it's not correct: `
` |
I changed my code to `
` but the result always are: inference time: 12ms Would you be able to give me some tips on how to resolve this? |
@sctrueew Have you try to use the .py to run inference. |
@wang-xinyu No, I haven't. It is my goal to use C++. |
@wang-xinyu as per the official release notes of v6.2 there is no significant architecture changes for detection models since release v6.0 hence detection models from v6.2 works here without any issue. |
@wang-xinyu also let me know , do you want me to update the README file for this PR specific changes, then i can raise separate PR for the same. |
@xiang-wuu If you can verify the detection model on v6.2 branch, that will be great. We can update the readme after that. |
As i mentioned earlier, i verified that and it's working fine. |
@xiang-wuu, |
@sctrueew @xiang-wuu I have updated the cpp code, the c++ inference is working now, can you check? |
@wang-xinyu Thanks. I've updated the code to the latest version and tested it but I don't know how to display the result after doInference. I'm using this to display: Is it correct? ` std::unordered_map<float, int> prob_index;
|
@sctrueew Cpp postprocessing is also added, please check. |
@wang-xinyu Thanks for the implementation. I've tested but the result is always this for all images: ../giraffe.jpg |
* updated gen_wts script to support yolov5 classfication model export * updated yolov5-s architecture to support classification head. * updated yolov5_trt infer script to support yolov5 classification model alongwith existing detection model. * added imagenet_classes file to load list of 1k classes required for the infer script. * final conv block doesn't require dynamic scale factor for out channel, hence hardcoded value provided to support all model varients * yolov5.cpp reverted back to original state, with explicit code changes * python infer script reverted back to prior state, with explicit code changes * seperate cpp file added for yolov5 classification task * cmake updated for yolo5 classification file * seperate python infer script for classification task * cmake updated by replacing cuda_add_executable with add_executable * default value added to the type argument * post-processing removed from yolov5 clasisifcation module * pre-processing for yolov5 classification inferencing * classification macro removed from the original yolov5 detection cpp file * reverted some extremely minor formatting changes. * reverted back to prior state by removing all formatting changes.
This PR will update the Yolov5 TRT network to support Yolov5 classification model serialization and inference as per the recent yolov5-v6.2, this PR can be linked to issue #1077, and cover below tasks.
gen_wts.py
script to support Yolov5 classification model export.build_engine
TRT network definition to initially support Yolov5s modelbuild_engine
TRT network definition to support all models