Skip to content

Instantly share code, notes, and snippets.

View hwaxxer's full-sized avatar

Martin Hwasser hwaxxer

View GitHub Profile
Package Version
------------------------ --------------------
argcomplete 2.0.0
arrow 1.2.2
attrs 19.3.0
Automat 0.8.0
binaryornot 0.4.4
blinker 1.4
certifi 2019.11.28
chardet 3.0.4
def wb_mask(img, y_pred, y_true):
labels = {
0: 'normal',
1: 'anomaly'
}
return wandb.Image(img, masks={
'prediction' : {'mask_data' : y_pred, 'class_labels' : labels},
'ground truth' : {'mask_data' : y_true, 'class_labels' : labels}})
def extract_patches(x,):
ksizes = [1, PATCH_WIDTH, PATCH_HEIGHT, 1]
strides = [1, 16, 16, 1]
rates = [1, 1, 1, 1]
padding = 'SAME'
return tf.image.extract_patches(x, ksizes, strides, rates, padding)
def extract_patches_inverse(x, y, tape):
_x = tf.zeros_like(x)
_y = extract_patches(_x)
@hwaxxer
hwaxxer / NSString+Hex.swift
Last active May 9, 2022 10:54
How to convert hexadecimal string representations to unicode. For example "The 0x1f511 to 0x1f48e is turning 0x1f34b into 0x1f379" becomes "The 🔑 to 💎 is turning 🍋 into 🍹"
extension NSString {
func stringByConvertingHexToUnicode() -> NSString {
var replaced = ""
var scanned: NSString?
let scanner = NSScanner(string: self as String)
while !scanner.atEnd {
if scanner.scanUpToString("0x", intoString: &scanned), let s = scanned {
replaced.appendContentsOf(s as String)
}