Skip to content

Instantly share code, notes, and snippets.

@Logrus
Logrus / image_learning.py
Last active September 13, 2023 13:36
Memorize an image with NN, made to play around with sin activation, positional encodings and etc.
"""
Recently Implicit Neural Representations gain popularity.
One of the issues there though is that the learned representations
are low-frequency biased, resulting in over-smoothed representations.
There has been a few approaches suggested to alleviate the issue,
for example by using positional encodings.
An alternative could be using Sin/Cos activation functions,
which in essence present a learnable basis functions.
@Logrus
Logrus / extract_images_from_bagfile.py
Created July 20, 2020 16:05
Dump sensor_msgs/CompressedImage from bagfile into a folder as png or jpeg files
#!/usr/bin/env python3
"""Extract sensor_msgs/CompressedImage from bagfile and save into a folder as png or jpeg files
Example usage:
./extract_images_from_bagfile.py bagfile.bag "/camera_topic" output_folder/images
Then files will be saved inside:
output_folder/images/image_1594120767.5438294.jpeg
output_folder/images/image_1594120767.8838294.jpeg
output_folder/images/image_1594120767.9538294.jpeg
showasm() {
$1++ $2 -O$3 -std=c++2a -S -masm=intel -o _temp_name.s && cat _temp_name.s | c++filt | grep -vE '\s+\.' > _temp_name_.s && rm _temp_name.s && vim _temp_name_.s
}
cat *.log | grep -o ".Loss.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*" > loss_values.txt
gnuplot <<- EOF
set terminal dumb
set xlabel "Iterations"
set ylabel "Loss"
plot "loss_values.txt"
EOF
#!/bin/bash
cat *log | grep -o ".Loss.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*" > loss_values.txt
num=51
if [ $# -eq 1 ]; then
num=$1
fi
python -c "import numpy as np; from scipy.signal import savgol_filter; y=np.loadtxt('loss_values.txt'); yh=savgol_filter(y, $num, 3); np.savetxt('smoothed_values.txt',yh);"
(
gnuplot <<- EOF
// Source: http://stackoverflow.com/questions/12791864/c-program-to-check-little-vs-big-endian
#include <stdio.h>
int main()
{
int x = 1;
char *y = (char*)&x;
if(*y){
printf("This computer is LITTLE endian.\n");
printf(" higher memory \n");
@Logrus
Logrus / .tmux.conf
Last active November 24, 2020 09:08
# Add to .bashrc
# alias tmux="TERM=screen-256color-bce tmux"
# Installing new tmux on 14.04
# sudo add-apt-repository ppa:pi-rho/dev
# sudo apt-get update
# sudo apt-get install python-software-properties software-properties-common
# sudo apt-get install -yqq tmux-next=2.3~20161028~bzr3606+20-1ubuntu1~ppa0~ubuntu14.04.1
# Add to .bashrc
# alias tmux="TERM=screen-256color-bce tmux-next"
@Logrus
Logrus / .vimrc
Last active October 19, 2016 09:46
vimconf
" Installing vundle, run:
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" after, run in vim
" :PluginInstall
"
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
struct point{
unsigned int x, y;
point() {};
point (int a, int b) {
x = a; y = b;
}
bool point::operator ==(const point &a){
return (x == a.x && y == a.y);
}
};
@Logrus
Logrus / CMakeLists.txt
Created April 5, 2014 07:27
PCL Viewer with Qt GUI minimal code
cmake_minimum_required(VERSION 2.6)
PROJECT(qt_vtk_pcl)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(PCL 1.7 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})