Wandb and accelerate

This commit is contained in:
shreygan21
2023-11-08 02:28:53 -08:00
parent a5f6dea673
commit 2d1a751441
3 changed files with 58 additions and 23 deletions
+17 -1
View File
@@ -34,4 +34,20 @@ def plot_batch(X, out_path):
rows = cols = math.ceil(rc)
canvas = tile(X, rows, cols)
canvas = np.squeeze(canvas)
PIL.Image.fromarray(canvas).save(out_path)
PIL.Image.fromarray(canvas).save(out_path)
def plot_batch_wandb(X):
"""Save batch of images tiled."""
n_channels = X.shape[3]
if n_channels > 3:
X = X[:,:,:,np.random.choice(n_channels, size = 3)]
X = postprocess(X)
rc = math.sqrt(X.shape[0])
rows = cols = math.ceil(rc)
canvas = tile(X, rows, cols)
canvas = np.squeeze(canvas)
print(canvas.shape)
print(rows, cols)
canvas = canvas[:2016, :2016,:]
# canvas = cv2.resize(canvas, None, fx=0.5, fy=0.5)
return canvas