From 03a1dd5bdbdd05cb2ab871d2a668bcc208632feb Mon Sep 17 00:00:00 2001 From: Sanjeev Kumar <87549675+sanjeev4427@users.noreply.github.com> Date: Thu, 18 Apr 2024 21:41:14 +0200 Subject: [PATCH] Expand dimension of patched training image Without expanding dimension the following error comes up in while executing code block 33: example = train_dataset[0] for k,v in example.items(): print(k,v.shape) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) in () ----> 1 example = train_dataset[0] 2 for k,v in example.items(): 3 print(k,v.shape) 6 frames /usr/local/lib/python3.10/dist-packages/transformers/image_utils.py in infer_channel_dimension_format(image, num_channels) 198 first_dim, last_dim = 1, 3 199 else: --> 200 raise ValueError(f"Unsupported number of image dimensions: {image.ndim}") 201 202 if image.shape[first_dim] in num_channels: ValueError: Unsupported number of image dimensions: 2 --- 331_fine_tune_SAM_mito.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/331_fine_tune_SAM_mito.ipynb b/331_fine_tune_SAM_mito.ipynb index 6c4d70761..b85ad0d47 100644 --- a/331_fine_tune_SAM_mito.ipynb +++ b/331_fine_tune_SAM_mito.ipynb @@ -186,6 +186,7 @@ " for j in range(patches_img.shape[1]):\n", "\n", " single_patch_img = patches_img[i,j,:,:]\n", + " single_patch_img = np.stack((single_patch_img,) * 3, axis=-1)\n", " all_img_patches.append(single_patch_img)\n", "\n", "images = np.array(all_img_patches)\n", @@ -2312,4 +2313,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +}