Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brookisme
brookisme / pytorch_weighted_categorical_crossentropy.py
Created August 29, 2018 20:01
Pytorch Weighted Categorical Crossentropy
import torch.nn as nn
import pytorch_nns.helpers as h
import pytorch_nns.functional as f
#
# HELPERS
#
def category_weights(
count_dict,
total=None,
@brookisme
brookisme / keras_weighted_categorical_crossentropy.py
Created August 29, 2018 19:58
Keras: Weighted Categorical Crossentropy
import numpy as np
import tensorflow as tf
import keras.backend as K
def weighted_categorical_crossentropy(weights):
""" weighted_categorical_crossentropy
Args:
* weights<ktensor|nparray|list>: crossentropy weights
@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
@brookisme
brookisme / unet-se.ipynb
Last active July 10, 2024 12:50
UNET with Squeeze and Excitation Blocks
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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),
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'