All the programs listed in this page are distributed under the GPL 3.0-only, with the exception of the emacs scripts which are under GPL 3.0-or-later.

You can browse all these projects on my git repository, or directly clone them from the provided URLs.


Here are a few programs directly related to my research.

A pytorch wrapper for the SVRT

tgz · git · readme

This is a wrapper for pytorch for the Synthetic Visual Reasoning Test, with an implementation of two deep networks and the machinery to train them with millions of examples.

The example of use in the provided test executable

labels = torch.LongTensor(12).zero_()
labels.narrow(0, 0, labels.size(0)//2).fill_(1)
x = svrt.generate_vignettes(4, labels)

produces a 3d tensor encoding 12 vignettes generated for the problem #4 of the SVRT, the first six of class 1, the last six of class 0, as pictured in the generated image.

A pytorch wrapper for a 2d physics simulator

tgz · git · readme

This is a wrapper for pytorch of a slightly improved version of the simulator used for dyncnn.

The example of use in the provided test executable

x = flatland.generate_sequence(False, 8, 16, 80, 80, 8, False, True)

produces a 5d tensor encoding 8 sequences of 16 images of resolution 80×80, each containing 8 shapes, as pictured in the generated image.

A pytorch function to save the autograd graph as a dot file

tgz · git · readme

This package provides a function that generates a dot file from the autograd graph, from which one can for instance generate a pdf file.

A typical use would be:

import torch

from torch import nn
from torch.nn import functional as fn
from torch import Tensor
from torch.autograd import Variable
from torch.nn import Module

import agtree2dot

class MLP(Module):
    def __init__(self, input_dim, hidden_dim, output_dim):
        super(MLP, self).__init__()
        self.fc1 = nn.Linear(input_dim, hidden_dim)
        self.fc2 = nn.Linear(hidden_dim, output_dim)

    def forward(self, x):
        x = self.fc1(x)
        x = fn.tanh(x)
        x = self.fc2(x)
        return x

mlp = MLP(10, 20, 1)
input = Variable(Tensor(100, 10).normal_())
target = Variable(Tensor(100).normal_())
output = mlp(input)
criterion = nn.MSELoss()
loss = criterion(output, target)

                    { input: 'input', target: 'target', loss: 'loss' },
                    open('./', 'w'))

which would generate a file, which can then be translated to pdf with

dot -Lg -T pdf -o mlp.pdf

to produce mlp.pdf.

A torch module to represent a DAG of modules

tgz · git · readme

The beauty of neural networks and deep learning is that an arbitrary directed acyclic graph of operators on tensors can be used and trained, as long as each operator is differentiable.

The torch framework provides lots of "modules" to implement basic operations (fully connected layer, convolution layer, ReLU, etc.), and to combine them in sequences or more complicated structures.

This dagnn package provides the nn.DAG container, which allows to combine modules in an arbitrary DAG, in a spirit similar to nngraph.

You can get it with

git clone

and run ./test-dagnn.lua for a simple example. It will generate a dot file from which you can generate graph.pdf.

For instance, the following piece of code:

dag = nn.DAG()

a = nn.Linear(50, 10)
b = nn.ReLU()
c = nn.Linear(10, 15)
d = nn.CMulTable()
e = nn.Mul(-1)

dag:connect(a, b, c)
dag:connect(b, nn.Linear(10, 15), nn.ReLU(), d)
dag:connect(c, d)
dag:connect(c, e)

dag:setOutput({ d, e })

implements the following network:

               +-- Linear(10, 10) --> ReLU --> d -->
              /                               /
             /                               /
  --> a --> b -----------> c ---------------+
                              +--------------- e -->

A simple profiler for torch

tgz · git · readme

This simple piece of code allows to decorate a torch model so that computation times during forward and backward passes are accumulated and can be printed in a concise manner.

You can get it with

git clone

and run ./test-profiler.lua for a simple example.

For instance, the following code

require 'torch'
require 'nn'
require 'profiler'

local input = torch.Tensor(100000, 20):uniform()
local target = torch.Tensor(input:size(1), 2):uniform()
local criterion = nn.MSECriterion()

local model = nn.Sequential()
   :add(nn.Linear(input:size(2), 1000))
   :add(nn.Linear(1000, target:size(2)))

profiler.color = false

local output = model:forward(input)
criterion:forward(output, target)
local dloss = criterion:backward(output, target)
model:backward(input, dloss)

profiler.print(model, input:size(1))


 nn.Sequential 3.03s [100.00%] (30.3mus/sample)
  :backward 1.94s [64.16%] (19.4mus/sample)
  :updateOutput 1.08s [35.84%] (10.8mus/sample)
  * nn.Linear 1.22s [40.41%] (12.2mus/sample)
    :backward 0.64s [21.24%] (6.4mus/sample)
    :updateOutput 0.58s [19.17%] (5.8mus/sample)
  * nn.ReLU 1.05s [34.62%] (10.5mus/sample)
    :backward 0.74s [24.30%] (7.4mus/sample)
    :updateOutput 0.31s [10.32%] (3.1mus/sample)
  * nn.Linear 0.76s [24.97%] (7.6mus/sample)
    :backward 0.56s [18.62%] (5.6mus/sample)
    :updateOutput 0.19s [6.34%] (1.9mus/sample)

A residual network to predict 2d dynamics

tgz · git

This is an attempt at predicting the dynamics of interacting objects with a "deep" network. I wrote a simple 2d physics engine in C++ that simulates moment of inertia, fluid frictions, and elastic collisions, and a residual network in Lua/Torch that predicts the final configuration of a set of rectangles, given a starting configuration and the location where a force is applied.

Results and analysis are available in Fleuret (2016), and you can have a look at a 2min video.

The Multi-Tracked Paths

tgz · git

This is an implementation of the multi-object tracking algorithm Multi-Tracked Paths, a variant of KSP that we developed for multi-camera pedestrian tracking (Berclaz et al. 2011). You can get more information and the reference implementation from the CVLab's web page about multi-camera tracking.

My implementation is very light, and requires no library. You can clone the repository with

git clone

and try it on a toy problem with

cd mtp
./mtp --verbose --trajectory-file result.trj --graph-file tracker.dat

If you have Graphviz installed, you can visualize the underlying graph and computed trajectories with

dot < -T pdf -o graph.pdf

Have a look at the README.txt file for a more detailed information.

Clueless k-means

tgz · git

This procedure is a variant of k-means using labelled samples, which enforces in every cluster the same proportion of samples from every class. This ensures that the resulting clusters are totally non-informative about the class, while maximally informative about the signal.

You can get a short report on the method, or clone the repository of the reference implementation with

git clone

Then, execute


to compile the source, run the algorithm on a 2d toy example, and produce three graphs (result-standard.png, result-clueless.png, and result-clueless-absolute.png) if you have gnuplot installed.

The Synthetic Visual Reasoning Test

tgz · git

Don Geman and I developed a series of synthetic image recognition problems which require to go beyond local descriptors and simple statistics of the image to be solved properly, and that we used to compare humans and machine-learning (Fleuret et al. 2011b).

You can clone the repository with

git clone

The Folded Coarse-to-Fine Detector

tgz · git

This is a detection algorithm we have developed for cat detection (Fleuret & Geman 2008). You can clone the repository with

git clone

and get the full data archive rmk-v1.0.tgz.

Have a look at the README.txt file for a more detailed information.

The Probabilistic Occupancy Map

tgz · git

The Probabilistic Occupancy Map is an algorithm to estimate an approximation of the marginal posterior probabilities of presence of individuals at different locations of an area of interest, given the result of a background subtraction procedure in different views. The camera calibrations are indirectly provided through a family of rectangles which approximate the silhouettes of individuals located at the considered locations. You can clone the repository with

git clone

You can have a look at the README.txt or to the section V and Appendix A of Fleuret al. (2008) for more information.

The CMIM learner

tgz · git

The Conditional Mutual Information Maximization is a feature-selection technique for two-class classification with binary features (Fleuret 2004). It is extremely fast (a few tens of a second learning for typical tasks), and when combined with a naive Bayesian learner it is very robust to over-fitting. Error rates are similar to those obtained with state of the art methods such as SVM or boosting.

Have a look at the README.txt file for a more detailed information.

You can clone the repository with

git clone

To use it, just execute It will create a training and test sets for a toy problem, run the various classifiers and display the error rates.


tgz · git

This is a small application to do very standard operations on data-sets, mainly as pre-processing for gnuplot. It can compute an histogram from a list of values, compute mean, variance, standard deviation, maximum and minimum values, compute the ROC curve or the ROC surface. This is not rocket science, but I use it often and it may be useful to others, too.

You can clone the repository

git clone

A multi-layer perceptron

tgz · git

I wrote, as a part of a larger project, a multi-layer perceptron in C++. On the MNIST data set, with the raw pixels in input, 200 hidden neurons, 10 output neurons with a winner-take-all rule and 40,000 examples for training, it achieves 3.42% error rate on the test set.

You can clone the repository with

git clone

The README.txt provides additional information.

Manipulate algebraic expressions in C++

tgz · git

This mapping class allows to manipulate formal expressions easily as if they were numerical values (i.e. operators and standard mathematical functions are defined).

You can clone the repository with

git clone

Have a look at the README.txt file for a more detailed information.

Linux tools

Here are a few application for Linux and other unices written in plain C.

Dynamic search in console

tgz · git · man

The selector command is a real-time interactive pattern matcher in console. It can be used to visit efficiently files in general, and shell history in particular. For the latter, contrary to what the readline C-r does, it does not show only one entry at a time, but restricts in real time the display to all the entries matching the pattern. You can at any time select one, which will be injected in the input buffer of the current tty.

Its aims are somehow similar to those of dmenu, but it is a pure tty command that can be used in console. You can read the selector man page for more information.

You can clone the repository with

git clone

It is general enough to be used with any shell, but was written for and tested with bash, and it has a short-cut option --bash, which is just equivalent to a bunch of other flags.

A bash-specific script is provided, so you just have to add to your ~/.bashrc

source --hist --cd

This will install a M-r bindings for a super history search, redefine the cd command to keep an history of the directories you visit, and install a key-bindings M-c to search it.

As far as I know, this software works on Linux amd64, Linux i386, Linux ARM, MacOS, and FreeBSD 8.0. The -v option is broken on the latter, since TIOCSTI is.

Indexing and searching in mboxes efficiently

tgz · git · man

The modern way of dealing with mails consists of keeping everything, and using search tools to retrieve rapidly mails from a certain sender, or related to a certain subject, etc. Multiple tools such as notmuch, or mu follow this philosophy.

My mymail command is similar in spirit, but simpler. It can visit directories recursively and create index files from all the mboxes it finds, or retrieve mails listed in such index files, whose senders, recipients, subject, etc. match specified regexps. The index files are flat text, with a bunch of lines for each mail.

The indexing takes into account fields which are usually ignored. For instance, the sender is defined by aggregating not only the From: field, but also Reply-to: and the leading "From " line of each mail. Check the mymail man page for more information.

The following command will index all the mbox files present in the directories ~/archives/mails/2010 and ~/archives/mails/2011 (recursively) and create an index file /tmp/mymail/2010-2011/mymail.db

mymail --db-file /tmp/mymail/2010-2011/mymail.db \
       --index \
       ~/archives/mails/2010 ~/archives/mails/2011

and the following one will search in all the database files *.db located (recursively) in /tmp/mymail, for all the mails having "bob.something" as sender or recipient, without "spam" in the subject, received over the last 31 days, and create an mbox file /tmp/mymail/mbox.

mymail --db-pattern '\.db$' --db-root /tmp/mymail \
       --output /tmp/mymail.mbox \
       --search 'p bob.something' \
       --search '!s spam' \
       --search 'month'

Despite not using a fancy database, both indexing and search are pretty fast. On my laptop (i7, ssd), it takes 20s to index 6.5Gb of mails, and 2s to retrieve 4150 mails and create the corresponding mbox. A standard search request takes less than a second.

You can get the source code, the man page, and a wrapper for the emacs email reader vm by cloning the repository with

git clone

It should compile under any reasonable POSIX system.

To use it under emacs, I have in my .emacs.el

(load "~/sources/gpl/mymail/mymail-vm.el")

(define-key vm-summary-mode-map "\\" 'mymail/vm-visit-folder)

(setq mymail/default-search-request "today"
      mymail/default-additional-search-requests "!s ^\\[SPAM\\]")

(add-to-list 'recentf-exclude "/tmp/mymail-vm-.*\.mbox")

and I modified the script I use to retrieve mails to automatically update the mymail indexes.

Size-sorting files and directories

tgz · git · man

The dus command computes the size of files and directories recursively and displays them sorted accordingly. You can clone the repository with

git clone

It compiles and works on Linux amd64, Linux i386, Linux ARM, and FreeBSD 8.0. You can read the dus man page for more information.

Find files common to different directories

tgz · git · man

The finddup command can find duplicated files in a given directory, files from one directory which exist also in another one, or files which exist in a directory and not in another one. It scan directories recursively, ignore symlinks and compares file sizes before checking their contents. You can clone the repository with

git clone

It compiles and works on Linux amd64, Linux i386, Linux ARM, and FreeBSD 8.0. You can read the finddup man page for more information.

Fan speed control daemon

tgz · git · man

This is a very simple daemon to control the fan speed. I used it on a Lenovo X61s for three years, then on a T420s, and now on a T450s without problem. However, there were no extensive test on other machines, nor by other people, so please use with care.

You can clone the repository with

git clone

The breezed man page and the README.txt provide additional information.

Emacs scripts

tgz · git

Here are some of the numerous scripts I wrote over the years for Emacs. You can clone the repository with

git clone

In particular, you will get my heavy emacs.el and vm configuration file.

An alarm if the current file is not under vc

The function defined in alarm-vc.el checks if the file loaded in the current buffer is under cvs, subversion or git and adds an alarm in the modeline if it is not while some files in the directory are. You just need to load the source file to activate the thing.

A word/character counter in the modeline

The function defined in text-counters.el automatically counts the number of words and characters in the region delimited by the previous line of "-" and the next line of "-" and displays them in the mode-line.

I activate it automatically when in text-mode with

(add-hook 'text-mode-hook 'tc/add-text-counters-in-modeline)

in my .emacs.el.

A dynamic string-selector

The function selector/select in selector.el is a dynamic regexp-matching interface. While you type, the buffer dynamically refreshes its content to show only the strings matching the regexp you have typed so far. It is very useful for instance to find files among those recently opened. You just have to add to your ~/.emacs.el

(require 'recentf)
(recentf-mode 1)

(when (load "selector" t t)
  (define-key global-map [(control x) (control r)] 'selector/quick-pick-recent)
  (define-key global-map [(control c) (control s)] 'selector/quick-move-in-buffer)
  (define-key global-map [(control x) (control b)] 'selector/switch-buffer)

Lookup words in the dictionary

If you often write things in English and need to lookup words, the lookup-dict.el command can be handy. It calls the dict command with either the content of the selected region or the word at point and displays the result in a new buffer. Just add

(load "lookup-dict.el")
(define-key global-map [(control \?)] 'lookup-dict)

in your ~/.emacs.el to associate that command to the C-? key.

Use mplayer under emacs

This is a major mode that provides a front-end to mplayer to avoid all those fancy GUIs young kids love those days. It displays your list of mp3 and web radios in a buffer and allows you both to control mplayer and organize sequences to play. It is still very primitive though. You can check this impressive screenshot.

I have the following in my ~/.emacs.el:

(when (load "media.el" nil t)

  (setq media/expert t
        media/history-size 1000
        media/playlist-file "~/private/media-playlists"
        media/mplayer-args '("-softvol" "-framedrop")
        media/url-list '("~/mp3"
                         ("" . "")
                         ("" . "Swiss Jazz")

  (define-key global-map [(meta \\)] 'media)

Press `?' to get a very short help, or look for the media/* in the binding list given by C-h b.

Handle rendez-vous and alarms

To remember rendez-vous, dead-lines and important things in general I wrote enotes.el, which can store notes, each associated to a date and a warning time. An alert pops up at the warning time, and a new warning time is automatically set. The whole stuff is simple and light to use. Here is a screenshot. Read the comments in the source to see how to use it.

I have the following in my ~/.emacs.el:

(when (load "enotes" nil t)
  (setq enotes/file "~/private/enotes")
  (define-key global-map [(control x) (control n)] 'enotes/show-all-notes))

Shell scripts

tgz · git

Here are my various handy shell scripts. Some were written ages ago are not relevant anymore.

You can clone the repository with

git clone


This bashrc for bash mainly sets the window title according to the current working directory, and do a few others things.

Control a DNS-323 from the command line

The DNS-323 is a cheap NAS under Linux. After some Googling, I could not find a simple recipe to shut it down from the command line. Hence here is a short script called to get the current status (temperature, RAID, etc.), restart it or shut it down. Use the -h flag to get the (concise) help.

Kill all useless xterms

Here is a short bash script to kill all open xterms which have only one bash as children and nothing else.

Old stuff

These are things I wrote a long time ago, some in my young age, which means for some of them in the 1990s. When no license is specified, consider the code to be distributed under the GPL 3.0.

A very primitive window class for X11

tgz · git

This is an extremely simple window class to make graphical output under X11. It needs no library beside libX11.

You can clone the repository with

git clone

A crosswords applet in Java (1998)

tgz · git

This applet is an interactive cross-words grid for web pages. Its source code is under the GPL 3.0.

Go to the crossword applet

To use it, first get the file crosswords.tgz and uncompress it in your public_html directory or equivalent (directory that contains your public files). You will obtain three class files (Words.class, Grid.class and Square.class). Then, you have to add an <applet> tag and the appropriate <param> in your HTML file.

You can clone the repository with

git clone

TropBot, an IRC bot (1996)

tgz · git

An IRC bot written in C++. Not the finest piece of software, I was not afraid of heavy string processing in C++ with pointers all over the place. Version 2.6.3a was surprisingly stable.

You can clone the repository with

git clone

Distort and smooth (1996)

tgz · git

The distort program corrects the "fish-eye" effect of the QuickCam. If you already tried to take pictures of scenes with lines, or just close-up portraits, you must have seen how the QuickCam distorts the image. For example, a homogeneous gride will be deformed like the top-row pictures.

To handle this, I wrote a small soft that distorts the image in such a way that the gride shown above gets back its homogeneous aspect. This soft is called distort and, given the a list of a distorted gride intersection coordinates, it distorts a picture to straight it out. Here are two examples of pictures before and after a correction.

The second program is supposed to help you improve the shade of gray. Maybe have you noticed that when you zoom on a quickcam picture, you can see a terrible pixel noise such as on the left picture. One can see on such picture two problems: First there is a random noise on the grey-scale levels, which can be corrected with a simple averaging on a few pictures. Second, there is a more structured noise. No idea if this phenomenon is standard on all QuickCam or not, but as you can see on this detail, odd columns are ligther than even ones. The program I propose here, called smooth, can perform both corrections. The picture on the right is an example of what can be done, using 32 pictures to compute the averaging, and using for reference picture a picture of a white wall, also smoothed with 32 pictures.

You can clone the repository with

git clone

The Tiny Tracer (1992)

tgz · git

As all people doing computer-science, I made a ray-tracer when I was young (as Frédo did). It was written in Modula-2, on an Amiga 500, and it was very slow. The objects were described as intersections of quadrics, and there wasn't any optimization. You can clone the repository with

git clone

or have a look at a few images it generated.

The turmites (1989)

tgz · git

A turmite is a kind of 2D Turing machine. It has an internal state, and at each step, depending on its internal state and the color of the cell it is on, it puts a new color in the cell, moves in one direction (ahead, right, left), and picks a new internal state. The idea comes from the French version of "Scientific American", and I made a program on Amiga to simulate a bunch of them, with some reproduction and mutation rules.

You can clone the repository with

git clone

to get the source and the binary files (which runs fine on Amiga emulators), you can look at a turmite written in Java below, or just look at what a bunch of them looks like.

You can also have a look at an applet demonstrating a live turmite. Its behavioral parameters are initially generated randomly, and you can then click on them to change their values. The Clear button clear the screen and the Random button generates a new random turmite.

Go to the turmite applet