Rect estimation for heatmap

from math import ceil image_size = 192 print("Input size: ", image_size) layers = [(3, 1, 'same'), (3, 1, 'same'), (3, 2, 'valid'), (3, 1, 'same'), (2, 2, 'valid'), (5, 1, 'valid'), (1, 1, 'valid')] trans = [] for k, s, p in layers: if p == 'valid': image_out = (image_size - (k - 1))/s scale = ((image_size - k + 1)/image_out) top = bottom = (k-1)/2 else: image_out = ceil(image_size/s) scale = (image_size/image_out) top = bottom = 0 image_size = image_out trans.append((scale, top, bottom)) print("Output size:", image_size) print("Transformations: ", trans) for s, t, b in reversed(trans): image_size = image_size*s + t + b print("Input size recovered", int(image_size)) point = [160, 160] print("Point on heatmap: ", point) for s, t, b in reversed(trans): point[0] = point[0]*s + t point[1] = point[1]*s + t point[0] = point[0] point[1] = point[1] print("Point on original image: ", point)

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.