Model trainer: Add provisional colouration
[?]
Jul 7, 2021, 12:07 AM
ABITXOUUKIF3XVFXVOQ5YI7N43TS5OEVNEFUQ5Q7J4QEILFG3IPACDependencies
- [2]
FYOPJXOXModel trainer: North/South comprise the Z axis in the source data - [3]
CWOSQTC4Trust tensorflow's thread safety (it wasn't the cause of an earlier bug) - [4]
QMNTEX7PTry a loss function that has higher values for errors near sea level - [5]
2ABZP2KNModel trainer: save map.png after training - [6]
ROQCAPZJBegin function for showing the map (for now just opens SDL window) - [7]
IGYI5RVVFigure out how to draw on the sdl2 window - [8]
6AXPZL5PTry to offload tight loop to rust (for now it segfaults) - [9]
4IXWCEHMGamma correction - [10]
ALMG52BOmodel trainer: speed up by waiting 15 seconds between monitor renders - [11]
7ML3OFE7Model trainer: initial train and visualize thread pair (total crust mass; todo: altitude instead) - [*]
E742MTJAFix segfault (don't pass pointers between functions in different SDL versions), minor refactor - [*]
5AMZXFS5model trainer: function to generate inputs to pass neural network for rendering equirectangular projection - [*]
ZM2EMAZOStart doing python multi-module stuff properly
Change contents
- edit in trainmodel/src/nativehelpers.py at line 14[14.532]
native.colourize_heightmap.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]colourize_heightmap = native.colourize_heightmap - replacement in trainmodel/src/model.py at line 29
y_true = tf.math.asinh(y_true - 4.94e-4)y_pred = tf.math.asinh(y_pred - 4.94e-4)y_true = tf.math.asinh(y_true - 0.1)y_pred = tf.math.asinh(y_pred - 0.1) - edit in trainmodel/src/helpers.rs at line 117
}}}#[no_mangle]pub extern "C" fn colourize_heightmap(target: *mut f64, source: *const f64, width: u32, height: u32) {const SEA_LEVEL: f64 = 0.1;let target = unsafe {std::slice::from_raw_parts_mut(target, (width as usize) * (height as usize) * 3)};let source = unsafe {std::slice::from_raw_parts(source, (width as usize) * (height as usize))};for y in 0 .. (height as usize) {let rowstart_s = y * (width as usize);let snow_line = {let y = (y as f64) / (height as f64);y * (1. - y) * 2.};for x in 0 .. (width as usize) {let ix = rowstart_s + x;let s = source[ix];let (r,g,b) = if s > snow_line {(1.,1.,1.)} else if s > SEA_LEVEL {let o = 0.9 * s;(o,0.9,o)} else {(0.,0.,0.9)};let ixt = ix * 3;target[ixt] = r;target[ixt + 1] = g;target[ixt + 2] = b; - replacement in trainmodel/src/drawmap.py at line 19
last_rendered = 0last_rendered = -15 - replacement in trainmodel/src/drawmap.py at line 23
outputs = tf.math.multiply(255, tf.reshape(outputs ** 0.35, (512, 1024, outputs.shape[1])))outputs = tf.math.multiply(255, colourize_heightmap(tf.reshape(outputs, (512, 1024, outputs.shape[1])))) - edit in trainmodel/src/drawmap.py at line 46[5.914]
def colourize_heightmap(source):shape = source.shapen = numpy.zeros((shape[0],shape[1],3), numpy.float64)source = tf.cast(source, tf.float64).numpy()helpers.colourize_heightmap(ctypes.cast(ctypes.c_voidp(n.ctypes.data), ctypes.POINTER(ctypes.c_double)), ctypes.cast(ctypes.c_voidp(source.ctypes.data), ctypes.POINTER(ctypes.c_double)), ctypes.c_int(shape[1]), ctypes.c_int(shape[0]))return tf.constant(n) - replacement in trainmodel/src/__main__.py at line 16
outputs = tf.cast(outputs ** 0.35 * 255, tf.uint8)outputs = tf.cast(drawmap.colourize_heightmap(outputs) * 255, tf.uint8)