Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions scripts/train_with_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ def compare(a, b):
# this is a hack to force wandb to log the images as JPEGs instead of PNGs
with tempfile.TemporaryDirectory() as tmpdir:
for i, image in enumerate(images):
pil = Image.fromarray((image[0].cpu().numpy().transpose(1, 2, 0) * 255).astype(np.uint8))
image_np = image[0].to('cpu').to(torch.float32).numpy()
pil = Image.fromarray((image_np.transpose(1, 2, 0) * 255).astype(np.uint8))
pil = pil.resize((256, 256))
pil.save(os.path.join(tmpdir, f"{i}.jpg"))
accelerator.log(
Expand Down Expand Up @@ -572,7 +573,7 @@ def compare(a, b):
# make sure we did an optimization step at the end of the inner epoch
assert accelerator.sync_gradients

if epoch!=0 and (epoch+1) % config.save_freq == 0 and accelerator.is_main_process:
if epoch!=0 and (epoch+1) % config.save_freq == 0:
accelerator.save_state()


Expand Down