diff --git a/docs/index.rst b/docs/index.rst index f3358a00f..b7c80404c 100755 --- a/docs/index.rst +++ b/docs/index.rst @@ -33,9 +33,19 @@ Documentation Index (as per sidebar) :caption: Python Documentation: Python Package Overview - Python Examples Python Class Documentation & Reference +.. toctree:: + :titlesonly: + :caption: Examples: + + Python Examples + C++ Examples + Android Mobile App Integration + Game Engine Godot Integration + Example Benchmark with Matrix Multiplication + Convolutional Neural Network (CNN) Simple Upscale + .. toctree:: :titlesonly: :caption: Advanced Concepts & Deep Dives: @@ -43,7 +53,5 @@ Documentation Index (as per sidebar) CI, Docker Images Docs & Tests Variable Types for Tensors, and Push/Spec Constants Asynchronous & Parallel Operations - Mobile App Integration (Android) - Game Engine Integration (Godot Engine) Code Index diff --git a/docs/overview/convolutional-net.rst b/docs/overview/convolutional-net.rst new file mode 100644 index 000000000..aed1673d7 --- /dev/null +++ b/docs/overview/convolutional-net.rst @@ -0,0 +1,3 @@ + +.. mdinclude:: ../../examples/neural_network_vgg7/README.md + diff --git a/docs/overview/matmul-benchmark.rst b/docs/overview/matmul-benchmark.rst new file mode 100644 index 000000000..8fb06eac8 --- /dev/null +++ b/docs/overview/matmul-benchmark.rst @@ -0,0 +1,12 @@ + +.. mdinclude:: ../../examples/python_naive_matmul/README.md + + +Implementation Overview +================ + +The benchmark can be found in the `benchmark.py` file in the repo, which is outlined below. This file runs a naive implementation of the three matrix multiplication implementations to evaluate the performance of each. + +.. literalinclude:: ../../examples/python_naive_matmuln/benchmark.py + :language: python + diff --git a/docs/overview/raspberry-pi.rst b/docs/overview/raspberry-pi.rst new file mode 100644 index 000000000..cd28bccbb --- /dev/null +++ b/docs/overview/raspberry-pi.rst @@ -0,0 +1,3 @@ + +.. mdinclude:: ../../examples/pi4_mesa_build/README.md + diff --git a/examples/neural_network_vgg7/.gitignore b/examples/neural_network_vgg7/.gitignore index 71319ea08..999940f78 100644 --- a/examples/neural_network_vgg7/.gitignore +++ b/examples/neural_network_vgg7/.gitignore @@ -1,3 +1,2 @@ model-kipper model.json -out.png diff --git a/examples/neural_network_vgg7/README.md b/examples/neural_network_vgg7/README.md index 3e6b06df7..49cd6d979 100644 --- a/examples/neural_network_vgg7/README.md +++ b/examples/neural_network_vgg7/README.md @@ -1,6 +1,17 @@ -# Waifu2x VGG7 implementation +# Convolutional Neural Network (CNN) VGG7 implementation -This demonstrates performing image upscaling using Python and kompute. +This example provides an implementation of a convolutional neural network (CNN) that enables for image resolution upscaling, which means that images can improve their quality through purely the machine learning implementation. + +This example demonstrates performing image upscaling using Kompute on the test image below. + +In this example we will be doing the following: + +* Import pre-trained model +* Create Kompute code that loads model weights +* Create Kompute shader that performs inference on image +* Run model against image to perform upscale + +## Import pre-trained model To import the no-noise-compensation VGG7 model (into `model-kipper`): @@ -11,7 +22,27 @@ python3 import_vgg7.py model.json Other models from the vgg\_7 set (such as `https://raw.githubusercontent.com/nagadomi/waifu2x/master/models/vgg_7/photo/noise0_model.json`) can be subsituted as desired. -To execute that model (no tiling is performed, so be careful about image sizes): +## Create code that loads model weights + +We implement the kompute logic under run_vgg7 that loads the model weights and coordinates the execution of the inference. + +## Create Kompute shader that performs inference on image + +Similarly, we created a compute shader that performs an inference iteration on an image provided to perfrom upscaling. + +## run model against image to perfrom upscale + +We now execute model against an image created by us to show how upscaling works. The image used will be the one below: + +![](w2wbinit.png) + +To execute that model no tiling is performed, so be careful about image sizes. + +We can now run the command below to perform inference against the image blow. `python3 run_vgg7.py w2wbinit.png out.png` +This would successfully upscale the resolution using the machine learning model, and the result is below: + +![](out.png) + diff --git a/examples/neural_network_vgg7/out.png b/examples/neural_network_vgg7/out.png new file mode 100644 index 000000000..ffb718eef Binary files /dev/null and b/examples/neural_network_vgg7/out.png differ