Skip to content
Snippets Groups Projects
Commit 41f9899d authored by Tommy Duc Luu's avatar Tommy Duc Luu
Browse files

saving function added v3

parent 9e9bfc77
No related branches found
No related tags found
No related merge requests found
...@@ -95,9 +95,9 @@ class Interactive: ...@@ -95,9 +95,9 @@ class Interactive:
else: else:
image = to_rgb_ad(x[:, :4].detach().cpu()) image = to_rgb_ad(x[:, :4].detach().cpu())
save_image(image, path, nrow=1, padding=0) save_image(image, path, nrow=1, padding=0)
return np.asarray(Image.open(self.imgpath))
# Do damage on model using pygame, cannot run through ssh # Do damage on model using pygame, cannot run through ssh
def interactive(self): def interactive(self):
x_eval = self.seedclone() x_eval = self.seedclone()
...@@ -147,12 +147,12 @@ class Interactive: ...@@ -147,12 +147,12 @@ class Interactive:
x_eval = self.seedclone() x_eval = self.seedclone()
x_eval = self.net(x_eval) x_eval = self.net(x_eval)
image = self.save_cell(x_eval, self.imgpath) self.save_cell(x_eval, self.imgpath)
cur_path = f'{self.logdir}/{counter}.png' cur_path = f'{self.logdir}/{counter}.png'
# Damage at 51: # Damage at 51:
if counter == 40: if counter == 40:
save_image(image, cur_path, nrow=1, padding=0) self.save_cell(x_eval, cur_path)
elif counter == 51: elif counter == 51:
# For lower half: # For lower half:
mpos_y = (self.size // 2) + 1 mpos_y = (self.size // 2) + 1
...@@ -167,7 +167,7 @@ class Interactive: ...@@ -167,7 +167,7 @@ class Interactive:
mpos_x:mpos_x + dmg_size] = 0 mpos_x:mpos_x + dmg_size] = 0
self.save_cell(x_eval, cur_path) self.save_cell(x_eval, cur_path)
elif counter == 60: elif counter == 60:
save_image(image, cur_path, nrow=1, padding=0) self.save_cell(x_eval, cur_path)
loss = self.net.loss(x_eval, self.pad_target) loss = self.net.loss(x_eval, self.pad_target)
self.writer.add_scalar("train/fit", loss, counter) self.writer.add_scalar("train/fit", loss, counter)
...@@ -182,7 +182,7 @@ class Interactive: ...@@ -182,7 +182,7 @@ class Interactive:
# damaged += 1 # damaged += 1
# Saving and loading each image as a quick hack to get rid of the batch dimension in tensor # Saving and loading each image as a quick hack to get rid of the batch dimension in tensor
image = np.asarray(Image.open(self.imgpath))
self.game_update(surface, image, cellsize) self.game_update(surface, image, cellsize)
time.sleep(0.00) # update delay time.sleep(0.00) # update delay
if counter == 400: if counter == 400:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment