X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=picoclvr.py;h=4906c65d610020a84c9c874dcd5399d07ce9bf46;hb=0d0c0088a1ff314035f31f22ea6a24e1f0975ed1;hp=a194a1cf9116cdc4a40c86898a9afae06322e9d2;hpb=68c17359790a9b8ac931a3679f08ad6a82a4e640;p=mygpt.git diff --git a/picoclvr.py b/picoclvr.py index a194a1c..4906c65 100755 --- a/picoclvr.py +++ b/picoclvr.py @@ -1,5 +1,10 @@ #!/usr/bin/env python +# Any copyright is dedicated to the Public Domain. +# https://creativecommons.org/publicdomain/zero/1.0/ + +# Written by Francois Fleuret + import torch, torchvision colors = [ @@ -22,6 +27,8 @@ color_names = [ color_tokens = dict( [ (n, c) for n, c in zip(color_names, colors) ] ) +###################################################################### + def generate(nb, height = 6, width = 8, max_nb_statements = 10): descr = [ ] @@ -41,10 +48,10 @@ def generate(nb, height = 6, width = 8, max_nb_statements = 10): for r, c in [ (k, color_names[shape_c[k]]) for k in range(nb) ]: s += [ f'there is {c}' ] - if shape_i[r] >= height - height/4: s += [ f'{c} bottom' ] - if shape_i[r] < height/4: s += [ f'{c} top' ] - if shape_j[r] >= width - width/4: s += [ f'{c} right' ] - if shape_j[r] < width/4: s += [ f'{c} left' ] + if shape_i[r] >= height - height//3: s += [ f'{c} bottom' ] + if shape_i[r] < height//3: s += [ f'{c} top' ] + if shape_j[r] >= width - width//3: s += [ f'{c} right' ] + if shape_j[r] < width//3: s += [ f'{c} left' ] for t, d in [ (k, color_names[shape_c[k]]) for k in range(nb) ]: if shape_i[r] > shape_i[t]: s += [ f'{c} below {d}' ]