Photo by Shahadat Rahman on Unsplash

OpenCV is an amazing library used by millions of developers around the world. Sadly the documentation is outdated and sometimes misleading. Here I present a working way to set up the latest (4.5.1 as of today, with 5.0 lurking around the corner) OpenCV to be used in Android Studio (4.1.1) and Kotlin.

Download the latest SDK

Sadly, you find a lot of wrong links and guides telling you to download version 2.4 or similar if you want to use OpenCV. No! Go to the official Sourceforge page (https://sourceforge.net/projects/opencvlibrary/files/) and select the latest version (4.5.1 as of 28 December 2020), inside the folder you find…


PyTorch recently released with version 1.3.0 their first Android version which allows you to run model inference on your smartphone. The set of functions is not very complete yet and the implementation has a few breaking bugs, but it’s a great and helpful step for using DNNs on your device.

Photo by Chris Ried on Unsplash

One function that is dearly missing is the option to convert the output of a model such as a UNet back from a tensor to a bitmap to show it to the user. I implemented this function in Kotlin and you can find it as a gist here: https://gist.github.com/phillies/830f52b0bf592c32fc507669694f66d8


In machine learning applications reproducibility is a key criterion, but random initialization and sampling can make it difficult. I show you a docker setup with jupyterlab and fastai/pytorch that automatically initializes the random seed on every startup, helping you to reproduce your results.

Photo by Evan Dvorkin on Unsplash

Reproducibility, the property that an experiment can be run again and will produce exactly the same results, is important not only from a scientific point of view. You want to be able to see if changes in your parameters are the reason you get better results and not the random initialization point of your network or the…


Photo by Neringa Šidlauskaitė on Unsplash

We recently got a new computer in the lab, an HP Z840 with two NVIDIA Geforce RTX 2080 Ti cards. Hardware issues with connecting the HP power supply to the graphics cards aside, installing Linux on this computer was a pain in the ass because of the secure boot setup. This tutorial might work for other computers which require secure boot.

Running Ubuntu 18.04.3 from a USB stick failed in the default configuration with secure boot enabled, after the booting process the display crashed and only smushed and squeezed pixels were shown. It always happened when the nouveau driver was…


Photo by Markus Spiske on Unsplash

Google Colab is amazing for doing small experiments with python and machine learning. But accessing data can be tricky, especially if you need large data such as images, audio, or video files. The easiest approach is storing the data in your Google Drive and accessing it from Colab, but Google Drive tends to produce timeouts when you have a large amount of files in one folder.

More robust and scalable is Google Cloud Storage, where you can also more easily share the data with colleagues. But unfortunately there is no native way to transfer data from Google Drive to Google…


Photo by frank mckenna on Unsplash

Docker is an amazing tool if you want to set up and try out software without having to clutter your operating system or build a clean environment for the app you’re developing. In this post I will show you step by step how to set up a docker file such that you can clone a private github repo and use the content built from that repo in a public image without having to worry about credentials or private files in the public image. As example I use building a vue.js …


Photo by Inactive. on Unsplash

When developing web apps you sometimes have to call APIs which you cannot host locally. This can get very annoying and time consuming if the API responses are very large, for example requesting high-resolution image data, and you have to call the API over and over again. One solution is to locally cache the API responses using a reverse proxy. This saved time and bandwidth and is surprisingly easy to set up on Windows.

The idea: set up an nginx webserver and configure it to act as reverse proxy for our API server and then call the local nginx server.


Photo by Chris Ried on Unsplash

When you write write code, especially in machine learning, there will be inevitably the situation where you loop over a larger amount of data, for example when you train your CNN. Progress bars are helpful in showing you how much work has been completed and how much longer you have to wait. My favorite progress bar for python is tqdm, which lets you create simple progress bars with just a few lines of code. The github page gives a very good introduction into the basic use of tqdm. Here a simple example:

import tqdm

for ii in tqdm.trange(100):
pass
100%|█████████████████████████████████████|…

Machine learning and neuroscience | Coding python (and recently JS and Kotlin) | Building apps you love

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store