projects
/
culture.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
5c751aa
)
Update.
author
François Fleuret
<francois@fleuret.org>
Sat, 22 Jun 2024 09:39:44 +0000
(11:39 +0200)
committer
François Fleuret
<francois@fleuret.org>
Sat, 22 Jun 2024 09:39:44 +0000
(11:39 +0200)
world.py
patch
|
blob
|
history
diff --git
a/world.py
b/world.py
index
1d86bc6
..
ab02c82
100755
(executable)
--- a/
world.py
+++ b/
world.py
@@
-27,9
+27,9
@@
colors = torch.tensor(
)
token_background = 0
)
token_background = 0
-first_
fish
_token = 1
-nb_
fish
_tokens = len(colors) - 1
-token_forward = first_
fish_token + nb_fish
_tokens
+first_
bird
_token = 1
+nb_
bird
_tokens = len(colors) - 1
+token_forward = first_
bird_token + nb_bird
_tokens
token_backward = token_forward + 1
token2char = "_" + "".join([str(n) for n in range(len(colors) - 1)]) + "><"
token_backward = token_forward + 1
token2char = "_" + "".join([str(n) for n in range(len(colors) - 1)]) + "><"
@@
-49,9
+49,9
@@
def generate(
f_end = torch.zeros(height, width, dtype=torch.int64)
n = torch.arange(f_start.size(0))
f_end = torch.zeros(height, width, dtype=torch.int64)
n = torch.arange(f_start.size(0))
- nb_
fish
= torch.randint(max_nb_obj, (1,)).item() + 1
+ nb_
birds
= torch.randint(max_nb_obj, (1,)).item() + 1
for c in (
for c in (
- (torch.randperm(nb_
fish_tokens) + first_fish_token)[:nb_fish
].sort().values
+ (torch.randperm(nb_
bird_tokens) + first_bird_token)[:nb_birds
].sort().values
):
i, j = (
torch.randint(height - 2, (1,))[0] + 1,
):
i, j = (
torch.randint(height - 2, (1,))[0] + 1,
@@
-109,7
+109,7
@@
def sample2img(seq, height, width, upscale=15):
def mosaic(x, upscale):
x = x.reshape(-1, height, width)
def mosaic(x, upscale):
x = x.reshape(-1, height, width)
- m = torch.logical_and(x >= 0, x < first_
fish_token + nb_fish
_tokens).long()
+ m = torch.logical_and(x >= 0, x < first_
bird_token + nb_bird
_tokens).long()
x = colors[x * m].permute(0, 3, 1, 2)
s = x.shape
x = x[:, :, :, None, :, None].expand(-1, -1, -1, upscale, -1, upscale)
x = colors[x * m].permute(0, 3, 1, 2)
s = x.shape
x = x[:, :, :, None, :, None].expand(-1, -1, -1, upscale, -1, upscale)