Printing RGB colors in the terminal

03/04/2023  ·  1 minute
Using terminal escape sequence: def print_rgb(r, g, b): print('\N{ESC}[48;' + f"2;{r};{g};{b}m " + '\u001b[0m', end="") This can be used in the following manner: import matplotlib cmap = matplotlib.colormaps["viridis"] for i in range(10): print_rgb(*[int(255 * c) for c in cmap(float(i / 10))[:-1]])

Fast online estimates on the GPU

06/08/2021  ·  4 minutes
Python PyTorch
Estimating moments is an important step of any statistical analysis of data. The mean, variance, skewness and kurtosis of a dataset can already tell a lot about the distribution of our data. However, some datasets don’t quite fit in memory. If you have a dataset of N samples and C features where N is a lot bigger than C, you can benefit a lot by using online algorithms. $$ \bar x = \frac 1N\sum_{i=1}^N x_i $$

Converting a python Dict into a class

07/12/2020  ·  1 minute
In python, dictionnaries and classes behave differently. One of the main difference is how you access their members. In the following example, class_instance and dictionnary hold the same data. class Foo: def __init__(self): = "foo" class_instance = Foo() dictionnary = {'bar': 'foo'} print(, dictionnary['bar']) # foo foo But in order to access the value of bar, the syntax is longer for the dictionnary and may not be convenient in cases where the class syntax is required.

Video Analysis

Fall 2020  ·  1 minute
Python PyTorch
As part of a project similar to the geometric deep learning analysis I did in Spring 2020, I investigated state of the art techniques in video action recognition. An example of tracking the activities of subjects The project was mostly about modifying the SlowFast model from FAIR to add person tracking. The modifications made to the model are available on this repository.

An analysis on US flights and cascading failures using PySpark

09/09/2020  ·  7 minutes
Python Spark
Introduction In this blog post, we are going to study a dataset of US only flights during the year 2007. The dataset was released by the American Statistical Association as part of their Bi-Annual Data exposition. During the competition, participants were asked to focus on only one question and try answering it by investigating the dataset. The question we are going to try to answer is: Can you detect cascading failures as delays in one airport create delays in others?

Geometric Deep Learning for face segmentation

Spring 2020  ·  27 minutes
Python Tensorflow Google Cloud
Study state of the arts models in the field of geometric deep learning. And then apply, by training models on a face segmentation dataset. We provide our fork of both the PointNet and PointNet++ models.