Skip to content

Instantly share code, notes, and snippets.

View kiyoon's full-sized avatar

Kiyoon Kim kiyoon

View GitHub Profile
@kiyoon
kiyoon / run_frcnn.sh
Last active November 30, 2019 20:28
Chooses 20 samples from the input directory and run Faster R-CNN
#!/bin/bash
if [ $# -lt 2 ]
then
echo "usage: $0 [input_dir] [output_dir]"
echo "chooses 20 video files randomly from the input directory and run Faster R-CNN"
exit 1
fi
input_dir="$1"
@kiyoon
kiyoon / Kdenlive YouTube 25p
Last active December 30, 2019 00:35
Kdenlive encoder settings for YouTube 25fps using ffmpeg. GOP (g) option should be half the frame rate. Note that it will output in a limited colour range (for TV) because of the yuv420p format. I use crf=15 for FHD and crf=12 for 4K videos.
c:v=libx264 preset=slow profile:v=high crf=%quality coder=1 pix_fmt=yuv420p movflags=+faststart g=12 bf=2 c:a=aac ab=%audiobitrate+'k' profile:a=aac_low f=mp4
@kiyoon
kiyoon / ffmpeg_nvidia_compress_video.sh
Created December 30, 2019 00:39
Compress a video file (specifically produced from Canon M50) using ffmpeg and NVIDIA hardware acceleration. Note that if colour settings are not specified, some players may use a limited colour range and display wrong colour.
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i <input.MP4> -c:v h264_nvenc -rc:v vbr_hq -cq:v 19 -b:v 10000k -maxrate:v 20000k -profile:v high -color_range pc -colorspace bt709 -color_trc bt709 -color_primaries bt709 -c:a copy <output.mp4>
@kiyoon
kiyoon / video_aug.sh
Created January 11, 2020 22:10
Generate video augmentation data
#!/bin/bash
if [ $# -lt 2 ]
then
echo "usage: $0 [input_dir] [output_dir] [output_resolution=224x224]"
echo "Crops the video into 4 corners and 1 centre, and flips the video horizontally to do the same, resulting in 10 augmentation per video."
exit 1
fi
input_dir="$1"
@kiyoon
kiyoon / docker-compose.yml
Last active February 7, 2020 19:29
Sample docker-compose file
#docker-compose.yml : Make container as described here.
#Author : Hyeonsu Lyu, hslyu@unist.ac.kr, +82 10-5117-9780
# Kiyoon Kim (kiyoon.kim@ed.ac.uk)
#First version, Jan. 30, 2019
version: '2'
services:
aislab-docker:
container_name: base_env
image: kiyoon/docker-for-ML:cuda10.1-cudnn7
@kiyoon
kiyoon / DALI_video_loader.py
Last active February 11, 2020 17:26
PyTorch video loader utilising GPU (CUDA) using NVIDIA DALI > 0.18.
from nvidia.dali.pipeline import Pipeline
from nvidia.dali.plugin import pytorch
import nvidia.dali.ops as ops
import nvidia.dali.types as types
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--file_list', type=str, default='file_list.txt',
help='DALI file_list for VideoReader')
@kiyoon
kiyoon / telegram_post.py
Last active January 1, 2021 06:34
Send Telegram messages (text, photos, and Matplotlib figures).
#!/usr/bin/env python3
# For command line usage, include the token and chat ids in advance in the script.
# If you want to use only the functions, there's no need to include this.
telegram_token = ""
# Get chat id by opening the URL: https://api.telegram.org/bot{token}/getUpdates
telegram_chat_ids = [""]
@kiyoon
kiyoon / human_time_duration.py
Last active June 11, 2021 14:46 — forked from borgstrom/human_time_duration.py
Python: Convert seconds (duration) to human readable string
TIME_DURATION_UNITS = (
('week', 60*60*24*7),
('day', 60*60*24),
('hour', 60*60),
('min', 60),
('sec', 1)
)
def human_time_duration(seconds):
@kiyoon
kiyoon / get_slurm_master_node.py
Created July 22, 2021 20:07
Get Slurm master node address from $SLURM_NODELIST
### get the first node name as master address
### e.g. master(aislab-[2-5],gnoded1) == aislab-2
import argparse
def get_parser():
parser = argparse.ArgumentParser(description="Extract master node name from Slurm node list",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("nodelist", help="Slurm nodelist")
return parser
@kiyoon
kiyoon / eddie_server.md
Last active August 17, 2021 05:15
Slurm cheatsheet

Node summary

qstat -F gpus,gputype,mem_total -q gpu

Interactive session

qlogin -pe gpu-titanx 1