{"id":13642860,"url":"https://github.com/msnh2012/Msnhnet","last_synced_at":"2025-04-20T21:31:52.688Z","repository":{"id":38350842,"uuid":"277270178","full_name":"msnh2012/Msnhnet","owner":"msnh2012","description":"🔥 (yolov3 yolov4 yolov5 unet ...)A mini pytorch inference framework which inspired from darknet.","archived":false,"fork":false,"pushed_at":"2023-04-23T15:29:11.000Z","size":15423,"stargazers_count":748,"open_issues_count":3,"forks_count":144,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-11-09T14:39:28.532Z","etag":null,"topics":["darknet","inference-engine","jetson-nx","mobilenetv2","mobilenetyolo","pytorch","yolov3","yolov4","yolov5"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msnh2012.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-07-05T09:31:24.000Z","updated_at":"2024-11-05T08:27:30.000Z","dependencies_parsed_at":"2022-08-09T03:01:33.102Z","dependency_job_id":"33277539-8898-46f4-80a5-dabb6f21f3d5","html_url":"https://github.com/msnh2012/Msnhnet","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msnh2012%2FMsnhnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msnh2012%2FMsnhnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msnh2012%2FMsnhnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msnh2012%2FMsnhnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msnh2012","download_url":"https://codeload.github.com/msnh2012/Msnhnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249965544,"owners_count":21352924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["darknet","inference-engine","jetson-nx","mobilenetv2","mobilenetyolo","pytorch","yolov3","yolov4","yolov5"],"created_at":"2024-08-02T01:01:37.379Z","updated_at":"2025-04-20T21:31:52.662Z","avatar_url":"https://github.com/msnh2012.png","language":"C++","funding_links":[],"categories":["*Ops for AI","Other Versions of YOLO"],"sub_categories":["Model Serving \u0026 Inference"],"readme":"# 🔥 Msnhnet(V2.0 Focusing on Robot Vision)🔥\r\nEnglish| [中文](ReadMe_CN.md) |[CSDN](https://blog.csdn.net/MSNH2012/article/details/107216704)\u003c/br\u003e\r\n###  A mini pytorch inference framework which inspired from darknet.\r\n![License](https://img.shields.io/badge/license-MIT-green)\r\n![c++](https://img.shields.io/badge/lauguage-c%2B%2B-green)\r\n![Msnhnet](https://img.shields.io/badge/Msnh-Msnhnet-blue)\u003c/br\u003e\r\n![](readme_imgs/banner.jpg)\u003c/br\u003e\r\n**OS supported** (you can check other OS by yourself)\r\n\r\n| |windows|linux|mac|Loongnix|\r\n|:---:|:---:|:---:|:---:|:--:|\r\n|checked|![Windows](https://img.shields.io/badge/build-passing-brightgreen.svg)|![Windows](https://img.shields.io/badge/build-passing-brightgreen.svg)|![OSX](https://img.shields.io/badge/build-passing-brightgreen.svg)|![Loongnix](https://img.shields.io/badge/build-passing-brightgreen.svg)|\r\n|gpu|![Windows](https://img.shields.io/badge/build-passing-brightgreen.svg)|![Linux](https://img.shields.io/badge/build-passing-brightgreen.svg)|![Mac](https://img.shields.io/badge/build-unknown-lightgrey.svg)|![Loongnix](https://img.shields.io/badge/build-unknown-lightgrey.svg)|\r\n\r\n**CPU checked**\r\n| |Intel i7|raspberry 3B|raspberry 4B|Jeston NX|Loongson|\r\n|:---:|:---:|:---:|:---:|:---:|:--:|\r\n|checked|![i7](https://img.shields.io/badge/build-passing-brightgreen.svg)|![3B](https://img.shields.io/badge/build-passing-brightgreen.svg)|![4B](https://img.shields.io/badge/build-passing-brightgreen.svg)|![NX](https://img.shields.io/badge/build-passing-brightgreen.svg)|![Loongson](https://img.shields.io/badge/build-passing-brightgreen.svg)|\r\n\r\n**Features**\r\n\r\n- C++ Only. 3rdparty blas lib is optional, also you can use OpenBlas.\r\n- OS supported: Windows, Linux(Ubuntu checked) and Mac os(unchecked).\r\n- CPU supported: Intel X86, AMD(unchecked) and ARM(checked: armv7 armv8 arrch64).\r\n- x86 avx2 supported.(Working....)\r\n- arm neon supported.(Working....)\r\n- A cv lib like opencv is supported for msnhnet.(MsnhCV) \r\n- conv2d 3x3s1 3x3s2 winograd3x3s1 is supported(**Arm**)\r\n- Keras to Msnhnet is supported. (Keras 2 and tensorflow 1.x)\r\n- GPU cuda supported.(Checked GTX1080Ti, Jetson NX)\r\n- GPU cudnn supported.(Checked GTX1080Ti, Jetson NX)\r\n- GPU fp16 mode supported.(Checked GTX1080Ti, Jetson NX.)\r\n- **ps. Please check your card wheather fp16 full speed is supported.**\r\n- c_api supported.\r\n- keras 2 msnhnet supported.(Keras 2 and tensorflow 1.x, part of op)\r\n- pytorch 2 msnhnet supported.(Part of op, working on it)\r\n- [MsnhnetSharp](https://github.com/msnh2012/MsnhnetSharp) supported.\r\n![pic](readme_imgs/ui.png)\r\n- A viewer for msnhnet is supported.(netron like)\r\n![](readme_imgs/msnhnetviewer.png)\r\n- Working on it...(**Weekend Only  (╮（╯＿╰）╭)**)\r\n\r\n**Tested networks**\r\n- lenet5\r\n- lenet5_bn\r\n- alexnet(**torchvision**)\r\n- vgg16(**torchvision**)\r\n- vgg16_bn(**torchvision**)\r\n- resnet18(**torchvision**)\r\n- resnet34(**torchvision**)\r\n- resnet50(**torchvision**)\r\n- resnet101(**torchvision**)\r\n- resnet152(**torchvision**)\r\n- darknet53[(Pytorch_Darknet53)](https://github.com/developer0hye/PyTorch-Darknet53)\r\n- googLenet(**torchvision**)\r\n- mobilenetv2(**torchvision**)\r\n- yolov3[(u版yolov3)](https://github.com/ultralytics/yolov3)\r\n- yolov3_spp[(u版yolov3)](https://github.com/ultralytics/yolov3)\r\n- yolov3_tiny[(u版yolov3)](https://github.com/ultralytics/yolov3)\r\n- yolov4[(u版yolov3)](https://github.com/ultralytics/yolov3)\r\n- fcns[(pytorch-FCN-easiest-demo)](https://github.com/bat67/pytorch-FCN-easiest-demo)\r\n- unet[(bbuf keras)](https://github.com/BBuf/Keras-Semantic-Segmentation)\r\n- deeplabv3(**torchvision**)\r\n- yolov5s🔥[(U版yolov5, for params)](https://github.com/msnh2012/Yolov5ForMsnhnet)\r\n- yolov5m🔥[(U版yolov5,for params)](https://github.com/msnh2012/Yolov5ForMsnhnet)\u003c/br\u003e\r\n==============================================================\r\n- mobilenetv2_yolov3_lite (cudnn does not work with GTX10** Pascal Card, please use GPU model only)\r\n- mobilenetv2_yolov3_nano (cudnn does not work with GTX10** Pascal Card, please use GPU model only)\r\n- yoloface100k (cudnn does not work with GTX10** Pascal Card, please use GPU model only)\r\n- yoloface500k (cudnn does not work with GTX10** Pascal Card, please use GPU model only)\r\n- Thanks: https://github.com/dog-qiuqiu/MobileNetv2-YOLOV3\r\n==============================================================\r\n- **pretrained models**. 链接：https://pan.baidu.com/s/1mBaJvGx7tp2ZsLKzT5ifOg \r\n提取码：x53z \r\n- **pretrained models**. Link : [Google Drive](https://drive.google.com/drive/folders/1tgTvA80rUnMqKVhB3Rb8sIGvKS98ARG3?usp=sharing)\r\n- Examples [here](https://github.com/msnh2012/Msnhnet/tree/master/examples).\r\n\r\n**Yolo Test** \r\n- Win10 MSVC 2017 I7-10700F\r\n\r\n  |net|yolov3|yolov3_tiny|yolov4|\r\n  |:---:|:---:|:---:|:---:|\r\n  |time|380ms|50ms|432ms|\r\n\r\n\r\n- ARM(Yolov3Tiny cpu)\r\n  |cpu|raspberry 3B|raspberry 4B|Jeston NX|\r\n  |:---:|:---:|:---:|:---:|\r\n  |with neon asm|?|0.432s|?|\r\n\r\n**Yolo GPU Test**\r\n- Ubuntu16.04  GCC  Cuda10.1  GTX1080Ti\r\n  |net|yolov3|yolov3_tiny|yolov4|\r\n  |:---:|:---:|:---:|:---:|\r\n  |time|30ms|8ms|30ms|\r\n  \r\n- Jetson NX\r\n  |net|yolov3|yolov3_tiny|yolov4|\r\n  |:---:|:---:|:---:|:---:|\r\n  |time|200ms|20ms|210ms|\r\n  \r\n**Yolo GPU cuDnn FP16 Test**\r\n- Jetson NX\r\n  |net|yolov3|yolov4|\r\n  |:---:|:---:|:---:|\r\n  |time|115ms|120ms|\r\n\r\n**Yolov5s GPU Test**\r\n- Ubuntu18.04  GCC  Cuda10.1  GTX2080Ti\r\n  |net|yolov5s| yolov5s_fp16|\r\n  |:---:|:---:|:---:|\r\n  |time|9.57ms| 8.57ms|\r\n\r\n**Mobilenet Yolo GPU cuDnn Test**\r\n- Jetson NX\r\n  |net|yoloface100k|yoloface500k|mobilenetv2_yolov3_nano|mobilenetv2_yolov3_lite|\r\n  |:---:|:---:|:---:|:---:|:---:|\r\n  |time|7ms|20ms|20ms|30ms|\r\n\r\n**DeepLabv3 GPU Test**\r\n- Ubuntu18.04  GCC  Cuda10.1  GTX2080Ti\r\n  |net|deeplabv3_resnet101|deeplabv3_resnet50|\r\n  |:---:|:---:|:---:|\r\n  |time|22.51ms|16.46ms|\r\n  \r\n**Requirements**\r\n  * OpenCV4 (**optional**) https://github.com/opencv/opencv\r\n  * Qt5 (**optional**. for Msnhnet viewer) http://download.qt.io/archive/qt/\r\n  * opengl(**optional**. for MsnhCV GUI) .\r\n  * glew(**optional**. for MsnhCV GUI) http://glew.sourceforge.net/ .\r\n  * glfw3(**optional**. for MsnhCV GUI) https://www.glfw.org/.\r\n  * cuda10+ cudnn 7.0+.(**optional**. for GPU)\r\n\r\n**Video tutorials(bilibili)**\r\n- [Build on Linux](https://www.bilibili.com/video/BV1ai4y1g7Nf)\r\n- [Build on Windows](https://www.bilibili.com/video/BV1DD4y127VB)\r\n- [Pytorch Params to msnhbin](https://www.bilibili.com/video/BV1rh41197L8)\r\n\r\n**How to build**\r\n- With CMake 3.15+\r\n- Viewer can not build with GPU.\r\n- Options\u003c/br\u003e\r\n![](readme_imgs/cmake_option.jpg)\u003c/br\u003e\r\n**ps. You can change omp threads by unchecking OMP_MAX_THREAD and modifying \"num\" val at CMakeLists.txt:52** \u003c/br\u003e\r\n\r\n- Windows\r\n1. Compile opencv4 **(optional)**\r\n2. Config environment. Add \"OpenCV_DIR\" **(optional)**\r\n3. Get qt5 and install. http://download.qt.io/ **(optional)**\r\n4. Add qt5 bin path to environment **(optional)**.\r\n5. Get glew for MsnhCV Gui.http://glew.sourceforge.net/ **(optional)**.\r\n6. Get glfw3 for MsnhCV Gui.https://www.glfw.org/ **(optional)**.\r\n7. Extract glew, add glew path to \"CMAKE_PREFIX_PATH\" **(optional)**.\r\n8. Compile gflw3 with cmake, add gflw3 cmake dir to \"GLFW_DIR\"  **(optional)**.\r\n9. Then use cmake-gui tool and visual studio to make or use vcpkg.\r\n\r\n- Linux(Ubuntu)\r\n\r\nps. If you want to build with Jetson, please uncheck NNPACK, OPENBLAS, NEON.\r\n\r\n```\r\n\r\nsudo apt-get install build-essential\r\nsudo apt-get install qt5-default      #optional\r\nsudo apt-get install libqt5svg5-dev   #optional\r\nsudo apt-get install libopencv-dev    #optional\r\nsudo apt-get install libgl1-mesa-dev libglfw3-dev libglfw3 libglew-dev #optional\r\n\r\n\r\n#config \r\nsudo echo /usr/local/lib \u003e /etc/ld.so.conf.d/usrlib.conf\r\nsudo ldconfig\r\n\r\n# build Msnhnet\r\ngit clone https://github.com/msnh2012/Msnhnet.git\r\nmkdir build \r\n\r\ncd Msnhnet/build\r\ncmake -DCMAKE_BUILD_TYPE=Release ..  \r\nmake -j4\r\nsudo make install\r\n\r\nvim ~/.bashrc # Last line add: export PATH=/usr/local/bin:$PATH\r\nsudo ldconfig\r\n```\r\n\r\n- MacOS(MacOS Catalina) Without viewer\r\n\r\nPS: XCode should be pre-installed. \r\n\r\nPlease download cmake from official website with gui support and the source code of yaml and opencv.\r\n\r\n```\r\n# install cmake\r\n\r\nvim .bash_profile\r\nexport CMAKE_ROOT=/Applications/CMake.app/Contents/bin/\r\nexport PATH=$CMAKE_ROOT:$PATH\r\nsource .bash_profile\r\n\r\n# install brew to install necessary libraries\r\n\r\n/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"\r\n\r\nbrew install wget\r\nbrew install openjpeg\r\nbrew install hdf5\r\nbrew install gflags\r\nbrew install glog\r\nbrew install eigen\r\nbrew install libomp\r\n\r\n# build yaml-cpp\r\ngit clone https://github.com/jbeder/yaml-cpp.git\r\ncd yaml-cpp\r\nmkdir build\r\nsource .bash_profile\r\ncmake-gui\r\nSet the source code path: ./yaml-cpp\r\nSet the build binary path: ./yaml-cpp/build\r\nconfigure\r\nCMAKE_BUILD_TYPE = Release\r\nuncheck YAML_CPP_BUILD_TESTS\r\nconfigure (and continue to debug)\r\ngenerate\r\ncd ./yaml-cpp/build\r\nsudo make install -j8\r\n\r\n# build opencv\r\n# download opencv.zip from official website(Remember to download opencv-contrib together)\r\ncd opencv-4.4.0\r\nmkdir build\r\nsource .bash_profile\r\ncmake-gui\r\n\r\n\r\nSet the source code path: ./opencv-4.4.0\r\nSet the build binary path: ./opencv-4.4.0/build\r\nconfigure (use default)\r\nsearch for OPENCV_ENABLE_NONFREE and enable it\r\nseach for OPENCV_EXTRA_MODULES_PATH to the path of opencv-contrib\r\nconfigure (and continue to debug)\r\ngenerate\r\ncd ./opencv-4.4.0/build/\r\nsudo make install -j8\r\n\r\n\r\n# build Msnhnet\r\ngit clone https://github.com/msnh2012/Msnhnet.git\r\nmkdir build \r\n\r\ncd Msnhnet/build\r\ncmake -DCMAKE_BUILD_TYPE=Release ..  \r\nmake -j4\r\nsudo make install\r\n```\r\n\r\n**Test Msnhnet**\r\n- 1. Download pretrained model and extract. eg.D:/models. \r\n- 2. Open terminal and cd \"Msnhnet install bin\". eg. D:/Msnhnet/bin\r\n- 3. Test yolov3 \"yolov3 D:/models\".\r\n- 4. Test yolov3tiny_video \"yolov3tiny_video D:/models\".\r\n- 5. Test classify \"classify D:/models\".\u003c/br\u003e\r\n\r\n![](readme_imgs/dog.png)\u003c/br\u003e\r\n\r\n**View Msnhnet**\r\n- 1. Open terminal and cd \"Msnhnet install bin\" eg. D:/Msnhnet/bin\r\n- 2. run \"MsnhnetViewer\"\r\n\r\n![](readme_imgs/viewer.png)\u003c/br\u003e\r\n\r\n**PS. You can double click \"ResBlock Res2Block AddBlock ConcatBlock\"  node to view more detail**\u003c/br\u003e\r\n**ResBlock**\u003c/br\u003e\r\n![](readme_imgs/ResBlock.png)\u003c/br\u003e\r\n\r\n**Res2Block**\u003c/br\u003e\r\n![](readme_imgs/Res2Block.png)\u003c/br\u003e\r\n\r\n**AddBlock**\u003c/br\u003e\r\n![](readme_imgs/AddBlock.png)\u003c/br\u003e\r\n\r\n**ConcatBlock**\u003c/br\u003e\r\n![](readme_imgs/ConcatBlock.png)\u003c/br\u003e\r\n\r\n**How to convert your own pytorch network**\r\n- [pytorch2msnhnet](https://github.com/msnh2012/Msnhnet/tree/master/tools/pytorch2Msnhnet)\r\n- **ps:**\r\n- 1 . Please check out OPs which supported by pytorch2msnhnet before trans.\r\n- 2 . Maybe some model can not be translated.\r\n- 3 . If your model contains preprocessors and postprocessors which are quite complicated, please trans backbone first and then add some OPs manually.\r\n- 4 . As for yolov3 \u0026 yolov4, just follow this [video](https://www.bilibili.com/video/BV1rh41197L8). You can find \"pytorch2msnhbin\" tool [here](https://github.com/msnh2012/Msnhnet/tree/master/tools/pytorch2msnhbin).\r\n\r\n**About Train**\r\n- Just use pytorch to train your model, and export as msnhbin.\r\n- eg. yolov3/v4 [https://github.com/ultralytics/yolov3](https://github.com/ultralytics/yolov3)\r\n\r\nEnjoy it! :D\r\n\r\n**Acknowledgement**\r\n\r\nMsnhnet got ideas and developed based on these projects：\r\n\r\n- [DarkNet](https://github.com/pjreddie/darknet)\r\n- [NCNN](https://github.com/Tencent/ncnn)\r\n- [ACL](https://github.com/ARM-software/ComputeLibrary)\r\n\r\n**3rdparty Libs**\r\n- [stb_image](https://github.com/nothings/stb)\r\n- [yaml-cpp](https://github.com/jbeder/yaml-cpp)\r\n- [imGui](https://github.com/ocornut/imgui)\r\n- [mpeg](https://github.com/phoboslab/pl_mpeg)\r\n\r\n**加群交流**\u003c/br\u003e\r\n![](readme_imgs/qq.png)\u003c/br\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsnh2012%2FMsnhnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsnh2012%2FMsnhnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsnh2012%2FMsnhnet/lists"}