Cutting-edge kidney tumor classification system! This project represents the culmination of my efforts, leveraging CUDA C++ and OpenCV to develop a sophisticated neural network for accurately classifying kidney tumors. Through extensive work, I have created a system that seamlessly integrates with a Golang server and is complemented by a React-powered frontend. Deployment on Azure AKS with GitHub Actions ensures streamlined deployment and management.
github kidney_tumor_CL_cudaC
\
Prerequisite Knowledge
- C++ Programming
- CUDA Programming
- Neural Networks (CNN2d, maxpool2d, liner, relu, sigmoid, batch normalization, flatten layer)
- OpenCV
- Server-side Development (basic golang)
- Frontend Development (basic react.js)
- Containerization and Orchestration (docker and kubernetes)
- Azure
- Continuous Integration/Continuous Deployment (Github actions)
Features
-
CUDA C++ Neural Network: At the core of this system is a robust neural network implemented entirely in CUDA C++, enabling efficient parallel processing and leveraging the power of GPUs for accelerated computations.
-
Golang Server Integration: The neural network seamlessly integrates with a Golang server, facilitating smooth communication between the backend and frontend components.
-
React Frontend: The frontend interface, powered by React, offers users an intuitive and interactive experience, allowing them to interact with the classification system effortlessly.
-
Deployment on Azure AKS: Leveraging Azure AKS (Azure Kubernetes Service) for deployment ensures scalability, reliability, and ease of management, providing a robust infrastructure for hosting the system.
-
GitHub Actions Deployment: The deployment process is streamlined using GitHub Actions, enabling continuous integration and deployment with minimal manual intervention.
Neural network architecture
The image shows a neural network architecture for image classification. The network takes an input image of size 225x225 and outputs a probability distribution over the possible classes. The network consists of several layers, including convolutional layers, ReLU activation layers, max-pooling layers, batch normalization layers, a flatten layer, linear layers, and a sigmoid activation layer.
The convolutional layers extract features from the input image. The ReLU activation layers introduce non-linearity into the network. The max pooling layers downsample the feature maps. The batch normalization layers normalize the activations. The flatten layer converts the feature maps into a single vector. The linear layers learn to classify the input image based on this vector. The sigmoid activation layer outputs a probability distribution over the possible classes.
Compilation
note: For learning purposes, I am building OpenCV from the source. If you want you can install it by apt-get install libopencv-dev
-
C++ Compilation: Initially, the CMake configuration compiles the C++ sources and creates a shared library (.so file) named app using CUDA for GPU acceleration and OpenCV for computer vision functionalities. This library contains the CUDA-accelerated neural network components.
-
Go Compilation: After the C++ compilation is completed, the CMake configuration invokes the Go compiler to compile the Go source file (app.go). The resulting executable is named backend.
-
Linking C++ Library with Go Executable: During the Go compilation step, the Go program (backend) is linked with the previously compiled C++ shared library (app.so). This linking allows the Go program to utilize the functionalities provided by the C++ library.
How to run this?
locally
Locally you need docker and docker compose. And Nvidia GPU with cuda v12.2
docker-compose -f docker-compose.build.yml build
you have to wait.
docker-compose -f docker-compose.build.yml up
web app will start on http://localhost:3000/. However, you still need to wait for the completion of the neural network training process. you can find kidney images inside " ./NN_backend/cuda_nn/kidney-ct-scan-image ".
Azure
I've developed a comprehensive CI/CD pipeline using GitHub Actions to seamlessly deploy applications onto the Azure cloud. workflow dir "./github/workflows/"
Required credentials
- AZURE_CLIENT_ID
- AZURE_TENANT_ID
- AZURE_SUBSCRIPTION_ID
- ACR_USERNAME
- ACR_PASSWORD
Please refer to the following link for instructions on obtaining the necessary credentials.
I used a service principal to enable authentication, and then employed OIDC methods for the login process.
In Azure, I created an application within the "App Registrations" section and assigned it the owner role with constrained permissions. Specifically, this application is only permitted to assign the AcrPull role to other resources like AKS.
And created a Container registry to push docker images.
CICD pipeline
Limitations and possible solutions
Speed
My CUDA C++ architecture exhibits high speed, though not as proficient as PyTorch.
Solution: Batter to use PyTorch and Python to create neural network architecture.
Development time
Writing anything from scratch in C++ is time-consuming.
Solution: Batter to use PyTorch and Python