my blog my blog

Category: Short
Python tips and tricks

Introducing jupyter-lab

Vim is all fun and games, but for interactivity, storytelling and presenting, or just interactive prototyping, nothing beets jupyter notebooks. Some fine guys have taken it one step further and introduced jupyter lab, which is a wrapper around our beloved notebooks. It offers easier kernel-selection, multi-window notebooks, built-in python consoles and some more.

Autoformatting Python Code

Sometimes, a lot of authors, editors and OSs mess up the indentations and style-conventions of your files.

Here is a astyle substitute for python-code: (sudo pip install autopep8)

autopep8 --in-place --aggressive --aggressive <filename>


Vim and Python

Put this modeline either in one of the first or last five lines of your python file:

# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

and put

set modeline

in your ~/.vimrc file.

Running Python Scripts

I still see a lot of students running python scripts like this:


In linux, we can make use of the shebang. This line, which has to be the very first line in your script, tells your system what program to use to run your script.
In case of python, this is a simple

#!/usr/bin/env python

followed by a

chmod +x

Now you are able to start the python script just like any other executable to run it:


I know, it only saves one word, but nevertheless I find it more convenient and wanted to share it with you.

Short: Schema diagram from an existing sqlite database

I have a sqlite-database which is just a little too big to keep in my head,

so I was searching for a way to create a nice diagram from the existing schema.
I have been trying a lot of tools, none of them delivered.

Now, with version 14.14.01 of schemacrawler, I was able to produce a nice plot!

./ -server sqlite -database /home/shared/data/TobisGpsSequence/sequences_960_720_manual.db -infolevel=maximum -password= -command=schema -outputformat=png -outputfile=test.png

(Please ignore the crazy database layout, I am in the middle of a migration and you are looking at the work-in-progress that caused me to again look around for nice visualizing tools)


Groundtruth data for Computer Vision with Blender

In the video below you can see the sequence of a car driving in a city scene and braking. The layers I rendered out for groundtruth data are the rendered image with the boundingbox of the car (top left), the emission layer ( shows the brakelights when they start to emit light, top right ), the optical flow (lower left), and the depth of each pixel in the world scene ( lower right).

Render-time was about 10h on a Nvidia GeForce GTX 680, tilesize 256×256, total image-size: 960×720. In this article I will first demonstrate how to set up the depth rendering, and afterwards how to extract, save and recover the optical flow.