X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=world.py;h=ab02c8240fcb70a28a7e112bcc3e29707dd1c69f;hb=31ed8a54992e7701eebd1c3d49bfe8dc20aa65e3;hp=1d86bc618f9cd8888d035c834e557ff86ae1baf1;hpb=8df319485a8a491a66f907d9c2cba7dd7fbe408e;p=culture.git diff --git a/world.py b/world.py index 1d86bc6..ab02c82 100755 --- a/world.py +++ b/world.py @@ -27,9 +27,9 @@ colors = torch.tensor( ) 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)]) + "><" @@ -49,9 +49,9 @@ def generate( 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 ( - (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, @@ -109,7 +109,7 @@ def sample2img(seq, height, width, upscale=15): 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)