projects
/
mygpt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
063e25c
)
Update.
author
Francois Fleuret
<francois@fleuret.org>
Wed, 11 May 2022 20:21:00 +0000
(22:21 +0200)
committer
Francois Fleuret
<francois@fleuret.org>
Wed, 11 May 2022 20:21:00 +0000
(22:21 +0200)
picoclvr.py
patch
|
blob
|
history
diff --git
a/picoclvr.py
b/picoclvr.py
index
4906c65
..
2342016
100755
(executable)
--- a/
picoclvr.py
+++ b/
picoclvr.py
@@
-34,18
+34,18
@@
def generate(nb, height = 6, width = 8, max_nb_statements = 10):
descr = [ ]
for n in range(nb):
descr = [ ]
for n in range(nb):
- nb
= torch.randint(5
, (1,)) + 1
- shape_position = torch.randperm(height * width)[:nb]
- shape_c = torch.randperm(
5)[:nb
] + 1
+ nb
_shapes = torch.randint(len(color_tokens) - 1
, (1,)) + 1
+ shape_position = torch.randperm(height * width)[:nb
_shapes
]
+ shape_c = torch.randperm(
len(color_tokens) - 1)[:nb_shapes
] + 1
shape_i = shape_position.div(width, rounding_mode = 'floor')
shape_j = shape_position % width
img = [ 0 ] * height * width
shape_i = shape_position.div(width, rounding_mode = 'floor')
shape_j = shape_position % width
img = [ 0 ] * height * width
- for k in range(nb): img[shape_position[k]] = shape_c[k]
+ for k in range(nb
_shapes
): img[shape_position[k]] = shape_c[k]
s = [ ]
s = [ ]
- for r, c in [ (k, color_names[shape_c[k]]) for k in range(nb) ]:
+ for r, c in [ (k, color_names[shape_c[k]]) for k in range(nb
_shapes
) ]:
s += [ f'there is {c}' ]
if shape_i[r] >= height - height//3: s += [ f'{c} bottom' ]
s += [ f'there is {c}' ]
if shape_i[r] >= height - height//3: s += [ f'{c} bottom' ]
@@
-53,7
+53,7
@@
def generate(nb, height = 6, width = 8, max_nb_statements = 10):
if shape_j[r] >= width - width//3: s += [ f'{c} right' ]
if shape_j[r] < width//3: s += [ f'{c} left' ]
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) ]:
+ for t, d in [ (k, color_names[shape_c[k]]) for k in range(nb
_shapes
) ]:
if shape_i[r] > shape_i[t]: s += [ f'{c} below {d}' ]
if shape_i[r] < shape_i[t]: s += [ f'{c} above {d}' ]
if shape_j[r] > shape_j[t]: s += [ f'{c} right of {d}' ]
if shape_i[r] > shape_i[t]: s += [ f'{c} below {d}' ]
if shape_i[r] < shape_i[t]: s += [ f'{c} above {d}' ]
if shape_j[r] > shape_j[t]: s += [ f'{c} right of {d}' ]