Rounding in Python

In school we round numbers like 0.5, 1123.5 towards the bigger number. It’s a “round half up” method. That introduces an undesired bias some cases. For example if we have a large data set, and we aggregate some column containing a lot of .5 fractions. In order to adjust for it in many cases a rounding of 0.5 towards nearest even number is applied. It’s “Rounding half to even” or “banker’s rounding”....

January 10, 2021 · SergeM

Symbolic math and python

With the help of python and SymPy module one can do pretty neat computations. For example when I took a course about Robotic Preception on Coursera I had to find a cross product of two vectors v1 x v2 represented in a generic form: v1 = (a, b, c) v2 = (d, e, 0) Normally I would write it down on a piece of paper and do the computations myself. Luckily python can help with that....

December 31, 2020 · SergeM

Effect of techniques from Fast.ai

fast.ai is a brilliant library and a course by Jeremy Howard an co. They use pytorch as a base and explain deep learning from the foundations to a very decent level. In his course Jeremy Howard demonstrates a lot of interesting techniques that he finds in papers and that do NN training faster/better/cheaper. Here I want to reproduce some of the techniques in order to understand what is the effect they bring....

November 15, 2020 · SergeM

Point cloud processing

ROS nodes Point Cloud IO https://github.com/ANYbotics/point_cloud_io two nodes for reading and writing PointCloud2 from/to ply, pcd formats point_cloud_assembler from laser_assembler http://wiki.ros.org/laser_assembler This node assembles a stream of sensor_msgs/PointCloud2 messages into larger point clouds. The aggregated point cloud can be accessed via a call to assemble_scans service. https://github.com/ros-perception/laser_assembler Tutorial Octomap http://octomap.github.io/ Seems like a standard solution to convert point clouds to a map in several formats pointcloud_to_laserscan http://wiki.ros.org/pointcloud_to_laserscan pcl_ros http://wiki.ros.org/pcl_ros This package provides interfaces and tools for bridging a running ROS system to the Point Cloud Library....

November 10, 2020 · SergeM

Python - Multiprocessing

Libraries Standard multiprocessing Pebble - pretty close to the standard one, but with a bit nicer interface Dask - well maintained and (almost) drop-in replacement of numpy and pandas: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # Arrays implement the Numpy API import dask.array as da x = da.random.random(size=(10000, 10000), chunks=(1000, 1000)) x + x.T - x.mean(axis=0) # Dataframes implement the Pandas API import dask....

October 1, 2020 · SergeM

Self-supervised depth and ego motion estimation

3D Packing for Self-Supervised Monocular Depth Estimation -------------------------------------------------------------- by Vitor Guizilini, `pdf at arxiv `_, 2020 Learning 1. Depth estimator :math:`f_D : I \rightarrow D` 2. Ego motion estimator: :math:`f_x : (I_t , I_S) \rightarrow x_{t \rightarrow S}` Depth Estimator ===================================== They predict an inverse depth and use a packnet architecture. Inverse depth probably has more stable results. Points far away from camera have small inverse depth that with low precision....

August 23, 2020 · SergeM

Which pretrained backbone to choose

In 2020 which architecture should I use for my image classification/tracking/segmentation/… task? I was asked on an interview that and I didn’t have a prepared answer. I made a small research and want to write down some thoughts. Most of the architectures build upon ideas from ResNet paper Deep Residual Learning for Image Recognition, 2015 Here is some explanation of resnet family:An Overview of ResNet and its Variants by Vincent Fung, 2017....

July 1, 2020 · SergeM

Parameters parsing for python applications

command line arguments is a standard and one of the most common ways to pass parameters to a python script. There exist a list of python libraries that help with that task. Here I am going to list some of them. argparse --------------------------- The default choice for the python developer. The module is included in python standard library and comes together with any python distribution. Example of usage: .. code-block:: #!...

April 21, 2020 · SergeM

Git cheat sheet

Nice history log in console ---------------------------------------- .. code-block:: git log --all --decorate --oneline --graph How to remember: "A Dog" = git log --**all** --**decorate** --**oneline** --**graph** Sample result: .. code-block:: $ git log --all --decorate --oneline --graph * e4689e3 (HEAD -> master, origin/master, origin/HEAD) tree iteration * 4c3385d using stoi * 0588a47 gitignore for cpp * 8f3f0e6 removed boost, add readme * f225b06 simple expression interpreter * 1ccdda1 chain of responsibility * f37eb7a restructure of the old code, removed large db file | * 3bfdf78 (tag: 0....

April 7, 2020 · SergeM

Image and video processing recipes

I often need to perform some operations on videos or image sequences. Usually I use linux and `ffmpeg`, and sometimes I struggle to remember all the commands. Here is a collection of recipes that I usually use with a bit of explanations. Video conversions ========================== Cut a range of frames --------------------------- Cut a range of frames (100, 130) from a video and save it to mp4 with a good quality using x264 codec: ....

March 27, 2020 · SergeM