Skip to content

Instantly share code, notes, and snippets.

View TomoshibiAkira's full-sized avatar

Elfina Ashfield TomoshibiAkira

View GitHub Profile
@TomoshibiAkira
TomoshibiAkira / img2awbmv2.py
Created January 6, 2022 14:03
A Python script for converting images to AWBMv2 (Award BIOS Bitmap V2).
import os
import argparse
import numpy as np
from PIL import Image
# Format description from: http://fileformats.archiveteam.org/wiki/Award_BIOS_logo
MAGIC = b'AWBM'
PALMAGIC = b'RGB '
def parse():
import tensorpack
from tensorpack.dataflow import (FakeData, MultiThreadMapData, MultiProcessMapData, imgaug, BatchData)
import numpy as np
import time
def test(x):
# simulate heavy workload
time.sleep(0.01)
x[0], _prms = aug.augment_return_params(x[0])
import tensorflow as tf
import numpy as np
def gen_one_hot(sess, h, w, input_dtype, one_hot_axis):
mat = np.random.rand(h, w) * 10
# matt has shape [h, w]
matt = tf.constant(mat, input_dtype, shape=mat.shape)
matt_oh = tf.one_hot(matt, depth=10, axis=one_hot_axis)
print (sess.run(matt_oh).shape)