Rosella Machine Intelligence & Data Mining | ||||
Computer Vision Machine Learning for Orange PI and Rock 5 SBCComputer Vision based on Machine Learning of Artificial Intelligence is a very promissing application area of Orange Pi Single Board Computers (SBC). Intelligent surveilance and monitoring functions can be embedded into Orange Pi applications, achieving edge computing. To see what applications you can develop with computer vision, you need to understand what computer vision models can do. It is important to understand that current computer vision technology has limitations. So limited applications are possible. Common computer vision modeling types include;
Computer Vision ModelingConvolutional Neural Networks (CNN) are used to model computer vision tasks. To do computer vision modeling, fairy good understanding of CNN is essential. Computer vision model development involves the following stages;
Computer vision machine learning is a very complex process. You need powerful but still easy to use and learn Machine Learning Software. CMSR Machine Learning Studio is a fully GUI based machine learning model development platform. You don't code anything until you embed CMSR generated model codes into your application projects. You just need to call a model function from your main program. Users can train machine learning models without coding. It's very easy to use and comes with powerful features. It provides the following types of computer vision modeling tools;
Powerful GPU and Large RAM Memory Computer is Essential!Computer vision is extremely compute intensive. Especially training will take huge computing time on powerful computers. The following shows times taken to train 104 layer computer vision deep neural network with 77 convolution layers on various GPUs. This is one epoch training time with 3,400 68x68 images.
You can see even high-end Intel internal GPUs can barely beat Orange Pi 5 GPU! Nvidia external GPU is outstanding. That's why everyone is rushing to buy Nvidia GPUs. More shading GPU cores are better as CMSR Studio can take advantage of bigger shading cores such as Nvidia Cuda cores. CMSR employes fine grained data parallelism. On 896 Nvidia Cuda cores, we observed 165 times fast than single CPU core model training. With more Cuda cores, it can get over 1,000 times fast. If Orange Pi 5 GPU is too slow for your projects, high performance gaming Windows PC with powerful external GPU from Nvidia or AMD is what you need. Note that CMSR Data Miner/Machine Learning Studio runs on Orange Pi 5 Linux distros with GPU acceleration. You can do both data analysis and computer vision model development on Orange Pi 5 as well as on Windows and MacOS. Model training is done with randomized order images. Otherwise, models will develop skews towards later images. To read images randomly, all training data images must be brought into main memory. Otherwise training will be extremely slow. You can estimate needed total RAM memory size in bytes with the following formula; total image dataset size = ((image width) * (image height) * 3 + 3) * (number of images) This should be your maximum image dataset size. For your computer RAM, it should be about twice of this size as OS will also use RAM. If you don't have large memory, you will have to content with small image training datasets. Note that this is CPU RAM size. GPU VRAM size is different. It can be much smaller as GPU VRAM stores only model parameters and some extras. Model Code Generation for Embedded ApplicationsForget about ChatGPT thing! CMSR ML Studio can generate highly efficient AI ML codes. CMSR ML Studio provides easy embedding into applications. Just generate program codes and compile with your project codes. Just call a function from your main code. CMSR can generate the following type codes;
generated programs incorporate pre- and post processing as follows;
For a generated program example, please see CMSR Generated Program Example: C++ OpenCL. Python developers will need to use Python-C++ bindings. Pure Python codes will be 80 times slower than C++ codes. So it's pointless to develop pure Python code generation. If OpenCL is supported, C++ OpenCL is recomended. Otherwise multicore version should be used. Generated Code Performance on Orange Pi 5Orane Pi is very impressive. It's very suitable for edge computing and computer vision. We tested 25 million parameter object detection computer vision model on Raspberry Pi 4B and Orange Pi 5 SBC computers. Results are as follows;
Orange Pi 5 OpenCL GPU performance is very impressive. It's suitable for large computer vision models. When 4 or 8 CPU threads are used, average power consumption is 11 watts during 13 or 14.5 seconds. When OpenCL GPU is used, average power consumption is only 8 watt during 0.68 second. GPU is more than 26 times more power efficient than CPUs. So the winner is Oprange Pi 5 OpenCL GPU. Note that you can enable OpenCL on Debian and Ubuntu for Orange Pi 5. Installation details can be found from the following link; You may also need OpenCV to capture camera images in RGB/BGR format. Installing OpenCV on OPi5 on Ubuntu and Debian, you may face two problems. One problem is that it requires 8GB main memory space to compile some modules. If your Opi5 has 4GB RAM, it will have 1.8GB swap space. Expand swap space to have additional 4GB as described here. Note that use "sudo fallocate -l 4G /swapfile" instead of "sudo fallocate -l 1G /swapfile" in the link. The other problem is that PNG library in your system may not be compatible with OpenCV. To avoid this problem, install OpenCV as described here. But use "cmake -DBUILD_PNG=ON ../opencv" command instead of "cmake ../opencv" described in the link. Embedding Models into ApplicationsCMSR generated codes are of very high efficiency. Especially in edge computing, efficiency and speed is one of the most important factors. All you need to code is what you actually use them. The following code shows usage of CNN classification model in C++. You will create a couple of arrays to receive results. Then call the main evaluate function with parameters. You can repeat "evaluate" function as much as you need in your applications. Of course, your applications should get image data from onboard camera! #include <iostream> #include "CMSRModel.hpp" using namespace std; int main(void) { char filename[] = "data/modelfile.cnn"; char imagefile[] = "data/cnnimages.rgb"; int IMAGEARRAY[64*64*3]; int outLabelCount = 4; int outLabelIndices[5]; float outLabelProbabilities[5]; int blackandwhite = 0; int r0g1b2 = 1; CMSRModel *model = new CMSRModel(); model->verbose = true; // initialize model; model->initializeModel(4, filename); // The following steps can be repeated many times; model->populateImageArray((int*)IMAGEARRAY, imagefile, 64*64*3); // you can get data from camera! model->evaluate ( outLabelCount, /* result label count */ outLabelIndices, /* ordered result output label indices */ outLabelProbabilities, /* ordered result output label relative probabilities */ blackandwhite, /* 1 if black and white, otherwise 0 */ r0g1b2, /* 1 if IMAGEARRAY[][][0] is red, otherwise 0 */ IMAGEARRAY /* [row/height][column/width][colors] */ ); cout << "Results;\n"; for (int i=0; i < outLabelCount; i++) { cout << i << ": " << outLabelIndices[i] << " / " << outLabelProbabilities[i] << "\n"; } // release memory resources; model->releaseMemoryResources(); delete model; cout << "End.\n"; return 0; } |
||||