-
Hi, we are doing a project with the data from https://warwick.ac.uk/fac/cross_fac/tia/data/glascontest/download/ Though we have run into some problems. We have done training and validation with the data converted to black and white, but it does not seem to work for the data in color. When working with the original images in colors, we get an error when creating the dataloader. Can you help us understand what goes wrong? Here is the code:import logging import torch import monai import matplotlib.pyplot as plt monai.config.print_config() data_dir = 'warwick' #loading training set into temporary dir for training training_data_size = len(images) print(len(images)) num_total = len(images) plt.subplots(3, 3, figsize = (8,8)) Model parameter definitionsnum_epochs = 100 Transformstrain_imtrans = Compose( Dataloadercheck_ds = ArrayDataset(images, train_imtrans, segs, train_segtrans) and when running, we get the following output:MONAI version: 0.8.0 Optional dependencies: For details about installing the optional dependencies, please visit: 145 === Transform input info -- RandSpatialCrop === === Transform input info -- RandSpatialCrop === === Transform input info -- RandSpatialCrop === === Transform input info -- RandSpatialCrop === File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/transforms/transform.py", line 82, in apply_transform File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/transforms/transform.py", line 53, in _apply_transform File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/transforms/croppad/array.py", line 535, in call File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/transforms/croppad/array.py", line 520, in randomize File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/utils/misc.py", line 180, in fall_back_tuple File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/utils/misc.py", line 137, in ensure_tuple_rep ValueError: Sequence must have length 1, got 2. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/transforms/transform.py", line 82, in apply_transform File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/transforms/transform.py", line 53, in _apply_transform File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/transforms/compose.py", line 160, in call File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/transforms/transform.py", line 106, in apply_transform RuntimeError: applying transform <monai.transforms.croppad.array.RandSpatialCrop object at 0x7fc49d5160d0> The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/name/OneDrive/DTU/5. semester/Projektarbejde/test.py", line 149, in File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/utils/misc.py", line 73, in first File "/Users/name/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 521, in next File "/Users/name/anaconda3/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 561, in _next_data File "/Users/name/anaconda3/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch File "/Users/name/anaconda3/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 49, in File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/data/dataset.py", line 1105, in getitem File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/data/dataset.py", line 96, in getitem File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/data/dataset.py", line 1002, in _transform File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/data/dataset.py", line 96, in getitem File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/data/dataset.py", line 82, in _transform File "/Users/name/anaconda3/lib/python3.9/site-packages/monai/transforms/transform.py", line 106, in apply_transform RuntimeError: applying transform <monai.transforms.compose.Compose object at 0x7fc49d16de80> |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
You say that you're using colour images (I'm assuming RGB), but when you print the image shape, e.g.: chosen image is:
warwick/train_77_anno.bmp
(522, 775) the images only seem to be 2-dimensional, i.e., they don't have a colour component. |
Beta Was this translation helpful? Give feedback.
-
Hello! I'm running into an error when applying some transforms?
The following is the displayed error: How can I solve it? |
Beta Was this translation helpful? Give feedback.
-
Here is the complete error log
…On Wed, Nov 1, 2023 at 15:19 YunLiu ***@***.***> wrote:
Hi @FerseinChris <https://github.com/FerseinChris>, could you please
share the whole error log? Thanks!
—
Reply to this email directly, view it on GitHub
<#3606 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQHEBDK3N62KOXBUMB7S4C3YCHZX7AVCNFSM5LPKE6U2U5DIOJSWCZC7NNSXTOKENFZWG5LTONUW63SDN5WW2ZLOOQ5TONBUGI4DQMY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
You say that you're using colour images (I'm assuming RGB), but when you print the image shape, e.g.:
the images only seem to be 2-dimensional, i.e., they don't have a colour component.