Skip to content

Instantly share code, notes, and snippets.

@brookisme
brookisme / tif2csv.sh
Last active August 1, 2016 14:50
Create CSV from Multiband-TIFF
#!/usr/bin/env python
function set_dir {
SOURCE_DIR=$1
if [ -z "$2" ]
then
TARGET_DIR=$1
else
TARGET_DIR=$2
fi
import os
import sys
import subprocess
from glob import glob
import gdal
import gdalconst as gc
import os
from time import time
from datetime import timedelta
from alert_config import TIF_DIR, CSV_DIR
#
# add to bashrc
#
# files
alias sampletree='mkdir -p sample/{train,test,valid}'
lsn(){ matchdir=`pwd`/$2; find $matchdir -type f | grep -v sample | shuf -n $1 | awk -F`pwd` '{print "."$NF}' ; }
# shuffle mv/cp
cpn(){ matchdir=`pwd`/$2; find $matchdir -type f | grep -v sample | shuf -n $1 | awk -F`pwd` '{print "."$NF" sample"$NF}' | xargs -t -n2 cp ; }
mvn(){ matchdir=`pwd`/$2; todir=`pwd`/$3; find $matchdir -type f | grep -v sample | shuf -n $1 | awk -F`pwd` -v todir="$todir" '{print $0" "todir}' | xargs -t -n2 mv ; }
@brookisme
brookisme / gcloud-gpu-setup.sh
Last active February 24, 2018 05:01
Google Cloud GPU Setup: Instructions & bash-script
#!/bin/bash
cd ~/
### CUDA
echo "\n\nChecking for CUDA and installing."
if ! dpkg-query -W cuda; then
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda -y
@brookisme
brookisme / setup.md
Last active November 8, 2017 07:36
FASTAI Instance ( setup to be used with http://course.fast.ai/ )

FASTAI SETUP

course codebase
cd ~/
mkdir usf
cd usf
# part1
git clone https://github.com/fastai/courses.git
@brookisme
brookisme / a_index.html
Created October 3, 2017 15:03 — forked from mappingvermont/a_index.html
TCD Tile Viewer - 2000 vs 2010
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>TCD Tile Comparison</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/0.7.7/leaflet.css" />
import sys
import httplib2
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.http import MediaFileUpload
KEY_FILE='/.config/gclib/sa_key.json'
FT_SCOPE = 'https://www.googleapis.com/auth/fusiontables'
DRIVE_SCOPE = 'https://www.googleapis.com/auth/drive'
@brookisme
brookisme / add_colormap_cli.py
Created July 19, 2018 22:56
Add Colormap To GeoTiff
from __future__ import print_function
import re
import click
import rasterio
CLR_IDENT='clr'
CMAP={
1: (48, 124, 38),
2: (138, 216, 168),
@brookisme
brookisme / unet-se.ipynb
Last active October 24, 2022 16:01
UNET with Squeeze and Excitation Blocks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brookisme
brookisme / multiprocess.py
Last active May 8, 2021 04:37
Python Multiprocessing Helpers: Map with Pool, ThreadPool and more
import itertools
from multiprocessing import Process, cpu_count
from multiprocessing import Pool
from multiprocessing.pool import ThreadPool
#
# CONFIG
#
MAX_POOL_PROCESSES=cpu_count()-1