Skip to content

Instantly share code, notes, and snippets.

View tkarna's full-sized avatar

Tuomas Kärnä tkarna

  • Intel
  • Finland
View GitHub Profile
@tkarna
tkarna / facedetect_train.ipynb
Created November 15, 2023 20:41
Face detect CNN training example notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tkarna
tkarna / facedetect_train.py
Created November 15, 2023 20:34
Face detect CNN training example
"""
Example adapted from https://github.com/aamini/introtodeeplearning lab2 part2
© MIT Introduction to Deep Learning
http://introtodeeplearning.com
"""
import tensorflow as tf
import matplotlib.pyplot as plt
import functools
import numpy as np
@tkarna
tkarna / gantt_chart.py
Created September 13, 2021 16:34
Simple Gantt chart
"""
Simple Gantt chart implementation
"""
from datetime import datetime as dt
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.dates import date2num
import matplotlib.dates as mdates
import numpy
@tkarna
tkarna / make_animation.sh
Last active May 31, 2021 18:46
Script to generate an mp4 video file from still images
#!/bin/bash
# generate mp4 animation from still images with ffmpeg.
if [ $# != 2 ]; then
echo "Usage: $(basename "$0") \"image/file/pattern_*.png\" output.mp4"
exit -1
fi
pattern=$1
outputfile=$2
@tkarna
tkarna / loop_month_days.sh
Created June 26, 2019 05:16
Loop through days of month in bash
#!/bin/bash
# loop through days of month given the first day
startdate="2019-06-01"
enddate=$(date -d "$startdate + 1 month" +"%Y-%m-%d")
ndays=$(( ($(date -d "$enddate" +%s) - $(date -d "$startdate" +%s) )/(60*60*24) ))
for i in $(seq 0 $(($ndays - 1)) ); do
@tkarna
tkarna / argparse_example.py
Last active February 21, 2019 18:52
Python argparse example demonstrating the most common usage options.
"""
Python argparse example demonstrating the most common usage options.
"""
import argparse
parser = argparse.ArgumentParser(
description='Description of the routine',
# includes default values in help entries
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
@tkarna
tkarna / install_slim_rigilk.sh
Created July 20, 2018 04:30
script for installing slim 3d on rigilk cluster
#!/bin/bash
# Install SLIM on rigilk cluster
source ~/bin/activate_gcc6.4
source ~/bin/activate_cmake-3.11.4
source ~/bin/activate_openmpi.sh
export BASEDIR=/home/karnat/sources/slim/install-script
mkdir -p $BASEDIR
@tkarna
tkarna / test_vert_int.py
Created February 2, 2017 20:14
Test strong vertical integral with pyop2
from thetis import *
"""
Computes a "strong" vertical integral of a field with pyop2
by integrating along the vertical 1D edges of the prism.
"""
def strong_integral_2d(source, output_2d, z_coords):
"""Computes strong integral of a P1DGxP1DG field onto P1DG 2D field"""
lc = 1.0/25.0;
Point(1) = {0, 0, 0, lc};
Point(2) = {1, 0, 0, lc};
Point(3) = {1, 1, 0, lc};
Point(4) = {0, 1, 0, lc};
Line(1) = {4, 3};
Line(2) = {3, 2};
Line(3) = {2, 1};
Line(4) = {1, 4};
Line Loop(5) = {1, 2, 3, 4};
@tkarna
tkarna / draw_golden_spiral.py
Created May 14, 2016 15:01
Draw Golden Spiral
"""
Draws Golden Spriral
Adapted from
http://junilyd.github.io/blog/2014/08/13/fibonacci-mystery-pythonified/
Tuomas Karna
2016-05-14
"""
import matplotlib.pyplot as plt