Ncnn deployment on mobile,support:YOLOv5s,YOLOv4-tiny,MobileNetV2-YOLOv3-nano,Simple-Pose,Yolact,ChineseOCR-lite,ENet,Landmark106,DBFace,MBNv2-FCN and MBNv3-Seg-small on camera.
iOS:
Xcode 12.4
macOS 11.2.3
iPhone 6sp 13.5.1
Android:
Android Studio 4.1
Win10 20H2
CPU:Qualcomm 710 GPU:Adreno 616
iOS
Select the model to be tested directly on the interface.
Android
Select the model to be tested directly on the interface.
Copy .param and .bin from "android_YOLOV5_NCNN\app\src\main\assets" to "iOS_YOLOv5NCNN\YOLOv5NCNN\res"
If it prompts that net.h can't be found, you need to download it from the ncnn official website or compile .framework(20201208) yourself and replace it in the project. If opencv2.framework(4.3.0) is useful, you need to download it again and replace it in the project.
The default library used by iOS does not include vulkan and bitcode.
Normally, you need to re-download ncnn.framework/glslang.framework/openmp.framework/opencv2.framework and replace it with the project.
For the configuration of Vulkan, please refer to the general configuration mentioned in Issues.
Android:
Due to factors such as mobile phone performance and image size, FPS varies greatly on different mobile phones. This project mainly tests the use of the NCNN framework. For the conversion of specific models, you can go to the NCNN official to view the conversion tutorial.
Because the opencv library is too large, only arm64-v8a/armeabi-v7a is reserved. If you need other versions, go to the official download.
ncnn temporarily uses the vulkan version, and acceleration needs to be turned on before loading, which is not turned on in this project. If you want to use the ncnn version, you need to modify the CMakeLists.txt configuration.
Different AS versions may have various problems with compilation. If the compilation error cannot be solved, it is recommended to use AS4.0 or higher to try.
This project is more about practicing the use and deployment of various models, without too much processing in terms of speed. If you have requirements for speed, you can directly obtain data such as YUV for direct input or use methods such as texture and opengl to achieve data input, reducing intermediate data transmission and conversion.
Convert locally(Will not upload model): xxxx -> ncnn
我训练了yolov5自己的模型,类别是1,在转成ncnn替换了YOLOv5_NCNN-master\iOS_YOLOv5NCNN\YOLOv5NCNN\res\yolov5.bin 和yolov5.param之后执行demo报错
2021-01-18 11:00:43.932899+0800 NCNN Demo[9473:20535076] new YoloV5
layer Shape_246 not exists or registered
我用的是最新版本的yolov5,version3训练的,我想知道作者yolov5demo用的是那个版本的?还有一个就是我修改了训练类别,这个直接替换文件还需要做什么操作吗?
Build command failed.
Error while executing process C:\Users\Administrator\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C C:\Users\Administrator\Desktop\ncnn\YOLOv5_NCNN-master\android_YOLOV5_NCNN\app.cxx\cmake\debug\x86 yolov5}
ninja: Entering directory `C:\Users\Administrator\Desktop\ncnn\YOLOv5_NCNN-master\android_YOLOV5_NCNN\app.cxx\cmake\debug\x86'
ninja: error: 'C:/Users/Administrator/Desktop/ncnn/YOLOv5_NCNN-master/android_YOLOV5_NCNN/app/src/main/cpp/opencv/x86/libopencv_java4.so', needed by 'C:/Users/Administrator/Desktop/ncnn/YOLOv5_NCNN-master/android_YOLOV5_NCNN/app/build/intermediates/cmake/debug/obj/x86/libyolov5.so', missing and no known rule to make it
1、从git上clonele ncnn进行编译之后对src/main/cpp/ncnn下的文件对应进行了替换
2、修改CMakeLists.txt文件为一下内容:
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
if(DEFINED ANDROID_NDK_MAJOR AND ${ANDROID_NDK_MAJOR} GREATER 20)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-openmp")
endif()
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
# 搜索当前目录下的所有.cpp文件
aux_source_directory(. SRC_LIST)
aux_source_directory(./ocr OCR_SRC_LIST)
add_library(
yolov5
SHARED
${SRC_LIST}
${OCR_SRC_LIST}
)
#add_library( # Sets the name of the library.
# yolov5
#
# # Sets the library as a shared library.
# SHARED
#
# # Provides a relative path to your source file(s).
# jni_interface.cpp
# YoloV5.cpp
# YoloV4.cpp
# SimplePose.cpp
# Yolact.cpp
# ocr/clipper.cpp
# ocr/NCNNDBNet.cpp
# ocr/ocr.cpp
# ocr/RRLib.cpp
# ocr/ZUtil.cpp
# ENet.cpp
# FaceLandmark.cpp
# DBFace.cpp
# MbnFCN.cpp
# MobileNetV3Seg.cpp
# YoloV5CustomLayer.cpp
# NanoDet.cpp
# )
include_directories(
ncnn/include
ocr
)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library(log-lib log)
find_library(android-lib android)
find_library(vulkan-lib vulkan)
find_library(jnigraphics-lib jnigraphics)
add_library( ncnn STATIC IMPORTED )
set_target_properties( # Specifies the target library.
ncnn
# Specifies the parameter you want to define.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
${CMAKE_SOURCE_DIR}/ncnn/${ANDROID_ABI}/libncnn.a )
# ncnnvulkan
add_library(glslang STATIC IMPORTED)
add_library(OGLCompiler STATIC IMPORTED)
add_library(OSDependent STATIC IMPORTED)
add_library(SPIRV STATIC IMPORTED)
set_target_properties(glslang PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/ncnnvulkan/${ANDROID_ABI}/libglslang.a)
set_target_properties(OGLCompiler PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/ncnnvulkan/${ANDROID_ABI}/libOGLCompiler.a)
set_target_properties(OSDependent PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/ncnnvulkan/${ANDROID_ABI}/libOSDependent.a)
set_target_properties(SPIRV PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/ncnnvulkan/${ANDROID_ABI}/libSPIRV.a)
# disable rtti and exceptions
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
# enable rtti and exceptions
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
include_directories(
${CMAKE_SOURCE_DIR}/opencv/include/
)
add_library(libopencv_java4 STATIC IMPORTED)
set_target_properties(
libopencv_java4
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/opencv/${ANDROID_ABI}/libopencv_java4.so
)
target_link_libraries( # Specifies the target library.
yolov5
# Links the target library to the log library
# included in the NDK.
${log-lib}
${vulkan-lib}
${android-lib}
${jnigraphics-lib}
libopencv_java4)
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
yolov5
# Links the target library to the log library
# included in the NDK.
${log-lib}
${vulkan-lib}
${android-lib}
${jnigraphics-lib}
ncnn
glslang SPIRV OGLCompiler OSDependent )
但是项目编译的时候会报:YOLOv5_NCNN/android_YOLOV5_NCNN/app/src/main/cpp/MbnFCN.cpp:15:20: error: no member named 'get_gpu_count' in namespace 'ncnn'
错误,请问这个大概是什么问题引起的呢
另:模型已按照
https://zhuanlan.zhihu.com/p/275989233
这个文章的方法进行转换并对文章内的图片demo进行测试没有问题,先想将模型放到这个项目当中。所以需要使用
YoloV5CustomLayer这个进行操作。
Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
A real time global illumination solution that achieves glossy surfaces, diffuse reflection, specular reflection, ambient occlusion, indirect shadows, soft shadows, emissive materials and 2-bounce GI.
This is a comprehensive project that combines the powerful computing capabilities of ESP32, with functions such as speech recognition, image recognition, GUI learning, and FFT music spectrum. It is suitable for learning image recognition algorithms and making LVGL-based UI interfaces.
Livox-Free-Space is a fast and effective free-space detection package using Livox LiDAR data. It based on traditional algorithm to segment 3D LiDAR data and generate free-space.
This respository implements a robust LiDAR-inertial odometry system for Livox LiDAR. The system uses only a single Livox LiDAR with a built-in IMU. It has a robust initialization module, which is independent to the sensor motion
AIfES (Artificial Intelligence for Embedded Systems) is a platform-independent and standalone AI software framework optimized for embedded systems. The Feedforward Neural Networks (FNN) implemented in AIfES can be freely parameterized, trained, modified or reloaded at runtime.
PPLNN, which is short for "PPLNN is a Primitive Library for Neural Network", is a high-performance deep-learning inference engine for efficient AI inferencing.