Image and signal asynchronous processing library. A lot of fun
Project description
Overview
Beatmup is an extensible asynchronous image and signal processing framework.
Beatmup is for image processing, mainly.
-
It enables low-level user-defined processing tasks execution
- in parallel and using hardware acceleration for the maximum speed,
- asynchronously, in an application-friendly fashion.
-
It implements basic building blocks and predefined processing operations:
- Image resampling and geometric operations
- Basic color filtering
- Flood fill and contour extraction
- Realtime rendering
Beatmup runs quite everywhere.
- Used in linux, Windows and Android
- Written in C++11, it has Java and Python bindings
- Prebuilt Python packages are available for x64 desktop Windows and Ubuntu-based linux distributions
- Few to no dependencies: Beatmup is extremely easy to build for a different platform
- git, CMake and a C++ compiler is all you need
- Beatmup compiles with gcc, clang and msvc
Beatmup speeds up processing by using GPU regardless its vendor, price and release year.
- It runs on
- desktop GPUs from mainstream vendors,
- integrated desktop GPUs,
- Android GPUs,
- Raspberry Pi GPU (all models including Pi Zero W),
- NVIDIA Jetson Nano,
- ...
- It uses the GPU for
- x2, neural network-based image upscaling technique,
- running inference of small user-defined neural nets,
- applying user-defined GLSL shaders to process images,
- realtime camera image processing in Android,
- scene rendering and predefined image processing tasks.
Highlights
x2: a neural net-based image upscaler
Beatmup is arguably the easiest way to get a fast hardware-accelerated neural network-based image superresolution running on any decent GPU. It does not provide a state-of-the-art PSNR score, but can run at a hundred of images per second on a desktop machine.
More details on the neural network design and the inference implementation: Inferring a super-resolution neural network on Raspberry Pi GPU
Update in 2.1 release: the fine-tuned version of the model (trained with multiple degradation kernels) achieves now 32.64 dB on DIV2K validation set compared to the initial score of 32.57 dB.
Available resources
Docs
- C++ documentation is available here. This is the most extensive documentation, it also contains additional explanations that do not relate to a specific programming language:
- Java package API documentation is here.
- Python documentation is here.
C++
There is a number of test apps showcasing the use of Beatmup with additional explanations in apps folder. The code is in C++, but can be universally helpful. Few examples:
- apps/shaderer processes images with a custom GLSL fragment shader read from the standard input.
- apps/x2 is a test app for the x2 neural net.
- apps/classify is a dog image classifier, a variant of ResNeXt trained on a subset of ImageNet containing 120 classes of dogs and cats images. The inference is implemented with OpenGL shaders. Top-1 validation accuracy achieved on Raspberry Pi Zero W is 72.08%. Classifying a 385*385 image takes ~595 ms there.
Python
python/examples folder contains detailed examples of scripts using Beatmup in Python.
- cifar100.py explains how to train a neural net with TensorFlow/Keras, convert it into a Beatmup-compliant model and run its inference on CIFAR100 test set.
- x2_superresolution.py and x2_superresolution_video.py showcase applying x2 upsampling neural net to an image and a video.
Unit tests in Python are available in python/tests/test.py and python/tests/test_nnets.py.
Java (Android)
An Android test app is available in android/app folder. It consists of independent examples showing how to use Beatmup in Android.
- BasicCameraUse.java shows how to get the camera preview, apply a simple shader and display the result.
- UpsamplingConvnetOnCamera.java implements the application of x2 upsampling neural net to the camera preview.
- DogClassifier.java implements the dog classifier taking the camera preview image as input.
Quick start: compiling Beatmup
To get things running, make sure you have git and CMake installed, then pick one of the following copy-paste recipes.
Linux
Building X2 app upscaling an image using a neural net inferred with OpenGL:
git clone https://github.com/lnstadrum/beatmup.git
cd beatmup
git submodule update --init --recursive
mkdir -p build && cd build
cmake -DUSE_GLX=ON ..
make X2
-
Try to use
-DUSE_OPENGL=ON
instead-DUSE_GLX=ON
starting from a clean build folder if you run into trouble. -
On Raspberry Pi prior to series 4 use the EGL backend with following CMake command:
cmake -DUSE_EGL=ON -DUSE_BRCM_LIBS=ON -DGLES_VERSION=20 ..
More details on Raspberry Pi setup here.
-
On Raspberry Pi 4 rather use the following CMake command:
cmake -DUSE_EGL_DRM=ON -DGLES_VERSION=20 ..
More details on Raspberry Pi 4 setup here.
Once the app is built, you can feed it with an image of your choice and get the upscaled result as follows:
./X2 <your-image>.bmp x2-result.bmp
Windows
To build the X2 app in Windows you may install Visual Studio and generate the VS solution as follows:
git clone https://github.com/lnstadrum/beatmup.git
cd beatmup
git submodule update --init --recursive
mkdir build && cd build
cmake -DUSE_OPENGL=ON ..
Then open the .sln solution file in Visual Studio and build the executable.
Android
There is Android project containing a library and a test app modules (lib and app). To build them install Android Studio and Android NDK bundle, clone the repository and open the project situated in android folder in Android studio.
You can build an apk in a docker container as well. Having docker installed, you can run the following script to build beatmupApp.apk installation package which you may then copy to your Android phone and open it there to install the test app:
git clone https://github.com/lnstadrum/beatmup.git
cd beatmup
git submodule update --init --recursive
docker build -f dockerfiles/android.Dockerfile -t beatmup-android .
docker run -v $(pwd):/opt/android-build beatmup-android
Quicker start with Python
Windows
Prebuilt python packages are available in 64-bit Windows for Python versions from 3.6 to 3.11:
python -m pip install --upgrade pip
python -m pip install beatmup
Ubuntu-based linux
Prebuilt packages for x64 desktop Ubuntu-based linux distributions are available for downloading on the releases page.
Compiling Python package
If there is no prebuilt package available for your platform/OS, you can easily build a Python wheel installable with pip
on your own.
First, get the code and try to compile an app as explained above. Then in the repository root folder run
cd build
make beatmup
cd ../python
python3 setup.py bdist_wheel clean
The installation package is now available in python/dist
folder. You can install it and make sure it works:
python3 -m pip install --no-index --find-links=dist beatmup
python3 -c "import beatmup; beatmup.say_hi()"
Licence and contributions
The project is licensed under the GNU GPL v3 licence.
The contributions are governed by the Contribution Licence Agreement (CLA). In short, under this Agreement you remain the copyright owner of your contribution, but you allow us to use and distribute your contribution under the terms of a possibly different licence.
If you want to contribute:
- make sure you own the copyright of your contribution,
- raise a pull request,
- send a signed CLA on beatmup.imaging@gmail.com.
Otherwise:
- raise an issue if you have a question or a feature request,
- contact us by email.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file beatmup-2.1.1-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: beatmup-2.1.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 720.8 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5e15fa93a15397ef744a7d46f9cfa976c334890129c4f6f77013a18aa41d44b |
|
MD5 | f16465f30ba0c3c6c737220271a85d39 |
|
BLAKE2b-256 | 3ecdc0d6a37e4f138905edf75c18a239bb9641569a55c5c7fd348b2ec7dd0e86 |
File details
Details for the file beatmup-2.1.1-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: beatmup-2.1.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 720.9 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06042822b443c49e1b959890dbadae66478640e31f2b33c6d65466678cfb5508 |
|
MD5 | f2d566ba87999e82f4878d2941f8b274 |
|
BLAKE2b-256 | 736bbaf75d3633c8ef28adf4d423fac3a3a0ffa0116ac55515e0f46db8ad3e29 |
File details
Details for the file beatmup-2.1.1-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: beatmup-2.1.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 706.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ca730252638d3ddaa7cd6247d2e912f0681ff4608a31dbd92a886798095fdbd |
|
MD5 | 0c9735d1fef0f0fbbc04cc4562ca6923 |
|
BLAKE2b-256 | c0b645b4bc48ec433a729f78fefa5098945a7406c6ed9807f907507a4a0476a2 |
File details
Details for the file beatmup-2.1.1-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: beatmup-2.1.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 720.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e8eb37bac0e588b9b5dd78a15ea494f24a32808e313f0f3c934ed0e52faf478 |
|
MD5 | 62fb995e7692f711706650967c0db04a |
|
BLAKE2b-256 | 9cbca0567f35e6a58a04c8bd96b6d1f3810badc3da6a6be7030b6180c9d78893 |
File details
Details for the file beatmup-2.1.1-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: beatmup-2.1.1-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 719.8 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fe380b26e61a84e29a4b86487364416d10f0cd2aa651db72bb9362c10b785a0 |
|
MD5 | 08245175ec995d8828d28fd4d4c6a0d8 |
|
BLAKE2b-256 | bcbea61919cd7e92ff937c3d6b90a47dfc4eccc3f93cd443d2ca1af98af0faee |
File details
Details for the file beatmup-2.1.1-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: beatmup-2.1.1-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 719.9 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05192e15041938547f23eeffeee71e2ead99b7d92dffeee420c22da80b00d848 |
|
MD5 | 119b1f8e3662f17a397a65a14a816543 |
|
BLAKE2b-256 | f455071ff12f88d5f8bbbe9e0e23e71aad17376b35b92c7038ac919667f4fbc7 |