Skip to content

Instantly share code, notes, and snippets.

@dkurt
Last active May 29, 2018 20:40
Show Gist options
  • Save dkurt/35295bdfb49c245fbb08894f9490f102 to your computer and use it in GitHub Desktop.
Save dkurt/35295bdfb49c245fbb08894f9490f102 to your computer and use it in GitHub Desktop.
from math import sqrt
min_scale = 0.2
max_scale = 0.95
num_layers = 6
aspect_ratios = [1.0, 2.0, 0.5, 3.0, 0.333]
image_width = 300
image_height = 300
scales = [min_scale + (max_scale - min_scale) * i / (num_layers - 1) for i in range(num_layers)] + [1.0]
for i in range(num_layers):
if i == 0:
widths = [0.1, min_scale * sqrt(2.0), min_scale * sqrt(0.5)]
heights = [0.1, min_scale / sqrt(2.0), min_scale / sqrt(0.5)]
else:
widths = [scales[i] * sqrt(ar) for ar in aspect_ratios]
heights = [scales[i] / sqrt(ar) for ar in aspect_ratios]
widths += [sqrt(scales[i] * scales[i + 1])]
heights += [sqrt(scales[i] * scales[i + 1])]
widths = [w * image_width for w in widths]
heights = [h * image_height for h in heights]
print widths
print heights
print ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment