Package: ncnn-vulkan
ncnn-vulkanThis fork aims to provide vulkan functionality to the ncnn python bindings, which is absent in the official package. All that is needed to use vulkan is the addition ofnet.opt.use_vulkan_compute = True.Also in this fork, failed vram allocation will result in a runtime error that is catchable, allowing you to clear the allocated vram on this error by usingncnn.destroy_gpu_instance().Minimal example:importcv2fromncnn_vulkanimportncnnimportnumpyasnpnet=ncnn.Net()# Use vulkan computenet.opt.use_vulkan_compute=True# Load model param and binnet.load_param("./x4.param")net.load_model("./x4.bin")ex=net.create_extractor()# Load image using opencvimg=cv2.imread("./example.jpg")# Convert image to ncnn Matmat_in=ncnn.Mat.from_pixels(img,ncnn.Mat.PixelType.PIXEL_BGR,img.shape[1],img.shape[0])# Normalize image (required)# Note that passing in a normalized numpy array will not work.mean_vals=[]norm_vals=[1/255.0,1/255.0,1/255.0]mat_in.substract_mean_normalize(mean_vals,norm_vals)# Try/except block to catch out-of-memory errortry:# Make sure the input and output names match the param fileex.input("data",mat_in)ret,mat_out=ex.extract("output")out=np.array(mat_out)# Transpose the output from `c, h, w` to `h, w, c` and put it back in 0-255 rangeoutput=out.transpose(1,2,0)*255# Save image using opencvcv2.imwrite('./out.png',output)except:ncnn.destroy_gpu_instance()original readmencnn is a high-performance neural network inference computing framework optimized for mobile platforms. ncnn is deeply considerate about deployment and uses on mobile phones from the beginning of design. ncnn does not have third party dependencies. It is cross-platform, and runs faster than all known open source frameworks on mobile phone cpu. Developers can easily deploy deep learning algorithm models to the mobile platform by using efficient ncnn implementation, create intelligent APPs, and bring the artificial intelligence to your fingertips. ncnn is currently being used in many Tencent applications, such as QQ, Qzone, WeChat, Pitu and so on.ncnn 是一个为手机端极致优化的高性能神经网络前向计算框架。ncnn 从设计之初深刻考虑手机端的部署和使用。无第三方依赖，跨平台，手机端 cpu 的速度快于目前所有已知的开源框架。基于 ncnn，开发者能够将深度学习算法轻松移植到手机端高效执行，开发出人工智能 APP，将 AI 带到你的指尖。ncnn 目前已在腾讯多款应用中使用，如 QQ，Qzone，微信，天天P图等。技术交流QQ群：637093648(超多大佬)  答案：卷卷卷卷卷 （已满）Pocky QQ群（MLIR YES!）: 677104663(超多大佬)   答案：multi-level intermediate representationTelegram Grouphttps://t.me/ncnnyesDiscord Channelhttps://discord.gg/YRsxgmFCurrent building status matrixSystemCPU (32bit)CPU (64bit)GPU (32bit)GPU (64bit)Linux (GCC)—Linux (Clang)—Linux (ARM)——Linux (MIPS)——Linux (RISC-V)———Linux (LoongArch)———Windows—Windows (ARM)——macOS——macOS (ARM)——AndroidAndroid-x86iOS—iOS Simulator——WebAssembly———RISC-V GCC/Newlib——Support most commonly used CNN network支持大部分常用的 CNN 网络Classical CNN:VGGAlexNetGoogleNetInception ...Practical CNN:ResNetDenseNetSENetFPN...Light-weight CNN:SqueezeNetMobileNetV1/V2/V3ShuffleNetV1/V2MNasNet...Face Detection:MTCNNRetinaFacescrfd...Detection:VGG-SSDMobileNet-SSDSqueezeNet-SSDMobileNetV2-SSDLiteMobileNetV3-SSDLite...Detection:Faster-RCNNR-FCN...Detection:YOLOv2YOLOv3MobileNet-YOLOv3YOLOv4YOLOv5YOLOv7YOLOX...Detection:NanoDetSegmentation:FCNPSPNetUNetYOLACT...Pose Estimation:SimplePose...HowTohow to build ncnn libraryon Linux / Windows / macOS / Raspberry Pi3 / Android / NVIDIA Jetson / iOS / WebAssembly / AllWinner D1 / Loongson 2K1000Build for Linux / NVIDIA Jetson / Raspberry Pi3Build for Windows x64 using VS2017Build for macOSBuild for ARM Cortex-A family with cross-compilingBuild for Hisilicon platform with cross-compilingBuild for AndroidBuild for iOS on macOS with xcodeBuild for WebAssemblyBuild for AllWinner D1Build for Loongson 2K1000Build for termux on androiddownload prebuild binary package for android and iosuse ncnn with alexnetwith detailed steps, recommended for beginners :)ncnn 组件使用指北 alexnet附带详细步骤，新人强烈推荐 :)use netron for ncnn model visualizationout-of-the-box web model conversionncnn low-level operation apincnn param and model file specncnn operation param weight tablehow to implement custom layer step by stepFAQncnn throw errorncnn produce wrong resultncnn vulkanFeaturesSupports convolutional neural networks, supports multiple input and multi-branch structure, can calculate part of the branchNo third-party library dependencies, does not rely on BLAS / NNPACK or any other computing frameworkPure C++ implementation, cross-platform, supports android, ios and so onARM NEON assembly level of careful optimization, calculation speed is extremely highSophisticated memory management and data structure design, very low memory footprintSupports multi-core parallel computing acceleration, ARM big.LITTLE cpu scheduling optimizationSupports GPU acceleration via the next-generation low-overhead vulkan apiExtensible model design, supports 8bit quantization and half-precision floating point storage, can import caffe/pytorch/mxnet/onnx/darknet/keras/tensorflow(mlir) modelsSupport direct memory zero copy reference load network modelCan be registered with custom layer implementation and extendedWell, it is strong, not afraid of being stuffed with 卷   QvQ功能概述支持卷积神经网络，支持多输入和多分支结构，可计算部分分支无任何第三方库依赖，不依赖 BLAS/NNPACK 等计算框架纯 C++ 实现，跨平台，支持 android ios 等ARM NEON 汇编级良心优化，计算速度极快精细的内存管理和数据结构设计，内存占用极低支持多核并行计算加速，ARM big.LITTLE cpu 调度优化支持基于全新低消耗的 vulkan api GPU 加速可扩展的模型设计，支持 8bit量化和半精度浮点存储，可导入 caffe/pytorch/mxnet/onnx/darknet/keras/tensorflow(mlir) 模型支持直接内存零拷贝引用加载网络模型可注册自定义层实现并扩展恩，很强就是了，不怕被塞卷 QvQsupported platform matrix✅ = known work and runs fast with good optimization✔️ = known work, but speed may not be fast enough❔ = shall work, not confirmed/ = not appliedWindowsLinuxAndroidmacOSiOSintel-cpu✔️✔️❔✔️/intel-gpu✔️✔️❔❔/amd-cpu✔️✔️❔✔️/amd-gpu✔️✔️❔❔/nvidia-gpu✔️✔️❔❔/qcom-cpu❔✔️✅//qcom-gpu❔✔️✔️//arm-cpu❔❔✅//arm-gpu❔❔✔️//apple-cpu///✔️✅apple-gpu///✔️✔️Example projecthttps://github.com/nihui/ncnn-android-squeezenethttps://github.com/nihui/ncnn-android-styletransferhttps://github.com/nihui/ncnn-android-mobilenetssdhttps://github.com/moli232777144/mtcnn_ncnnhttps://github.com/nihui/ncnn-android-yolov5https://github.com/xiang-wuu/ncnn-android-yolov7https://github.com/nihui/ncnn-android-scrfd🤩LicenseBSD 3 Clause