X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=sky.py;h=cc5bd4fd5cfedec896b88d7549d1b831ae2ef265;hb=5f5c6c079c2751a76887444c211c5c464e875ed0;hp=6ef8a3af2184777c223dfd1803647a49bd3dd54d;hpb=00f321c2e2a9b7be1edcb1453bf0d45f52e50919;p=culture.git diff --git a/sky.py b/sky.py index 6ef8a3a..cc5bd4f 100755 --- a/sky.py +++ b/sky.py @@ -50,7 +50,11 @@ class Sky(problem.Problem): speed=2, nb_iterations=2, avoid_collision=True, + max_nb_cached_chunks=None, + chunk_size=None, + nb_threads=-1, ): + super().__init__(max_nb_cached_chunks, chunk_size, nb_threads) self.height = height self.width = width self.nb_birds = nb_birds @@ -217,9 +221,11 @@ class Sky(problem.Problem): y[...] = c else: c = c.long()[:, None] - c = c * torch.tensor([0, 0, 0], device=c.device) + ( - 1 - c - ) * torch.tensor([255, 255, 255], device=c.device) + c = ( + (c == 1).long() * torch.tensor([0, 255, 0], device=c.device) + + (c == 0).long() * torch.tensor([255, 255, 255], device=c.device) + + (c == -1).long() * torch.tensor([255, 0, 0], device=c.device) + ) y[...] = c[:, :, None, None] y[:, :, di : di + x.size(2), dj : dj + x.size(3)] = x @@ -294,7 +300,7 @@ class Sky(problem.Problem): return prompts, answers - def save_quizzes( + def save_quiz_illustrations( self, result_dir, filename_prefix, @@ -322,10 +328,10 @@ if __name__ == "__main__": prompts, answers = sky.generate_prompts_and_answers(4) - predicted_prompts = torch.rand(prompts.size(0)) < 0.5 - predicted_answers = torch.rand(answers.size(0)) < 0.5 + predicted_prompts = torch.randint(3, (prompts.size(0),)) - 1 + predicted_answers = torch.randint(3, (prompts.size(0),)) - 1 - sky.save_quizzes( + sky.save_quiz_illustrations( "/tmp", "test", prompts, answers, predicted_prompts, predicted_answers )