Skip to content
Merged
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
4 changes: 4 additions & 0 deletions lucent/optvis/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ def closure():
def tensor_to_img_array(tensor):
image = tensor.cpu().detach().numpy()
image = np.transpose(image, [0, 2, 3, 1])
# Check if the image is single channel and convert to 3-channel
if len(image.shape) == 4 and image.shape[3] == 1: # Single channel image
image = np.repeat(image, 3, axis=3)
image = (image * 255).astype(np.uint8)
return image


Expand Down