Git Product home page Git Product logo

Comments (3)

SuzannaLin avatar SuzannaLin commented on July 19, 2024 1

Thanks for your quick reply! I will try that out and let you know how it goes :)

from cct.

yassouali avatar yassouali commented on July 19, 2024

Hi @SuzannaLin

The number of input channels is set in the backbone here, the layer name is conv1.

from cct.

SuzannaLin avatar SuzannaLin commented on July 19, 2024

so I have adjusted the number of input channels to 4, but I still get lots of issues. This is while doing augmentation:

0%| | 0/133 [00:01<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 87, in
main(config, args.resume)
File "train.py", line 71, in main
trainer.train()
File "/home/scuypers/CCT_4/base/base_trainer.py", line 91, in train
results = self._train_epoch(epoch)
File "/home/scuypers/CCT_4/trainer.py", line 66, in _train_epoch
(input_l, target_l), (input_ul, target_ul) = next(dataloader), (None, None)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 521, in next
data = self._next_data()
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data
return self._process_data(data)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
data.reraise()
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/_utils.py", line 434, in reraise
raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/scuypers/CCT_4/base/base_dataset.py", line 185, in getitem
image, label = self._augmentation(image, label)
File "/home/scuypers/CCT_4/base/base_dataset.py", line 175, in augmentation
return self.normalize(self.to_tensor(image)), label
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in call_impl
return forward_call(*input, **kwargs)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 226, in forward
return F.normalize(tensor, self.mean, self.std, self.inplace)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 351, in normalize
tensor.sub
(mean).div
(std)
RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0

When I set augmentation: False in the config, I get this error:

0%| | 0/133 [00:08<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 87, in
main(config, args.resume)
File "train.py", line 71, in main
trainer.train()
File "/home/scuypers/CCT_4/base/base_trainer.py", line 91, in train
results = self._train_epoch(epoch)
File "/home/scuypers/CCT_4/trainer.py", line 75, in _train_epoch
curr_iter=batch_idx, target_ul=target_ul, epoch=epoch-1)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 168, in forward
outputs = self.parallel_apply(replicas, inputs, kwargs)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 178, in parallel_apply
return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/parallel/parallel_apply.py", line 86, in parallel_apply
output.reraise()
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/_utils.py", line 434, in reraise
raise exception
RuntimeError: Caught RuntimeError in replica 0 on device 0.
Original Traceback (most recent call last):
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/parallel/parallel_apply.py", line 61, in _worker
output = module(*input, **kwargs)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/scuypers/CCT_4/models/model.py", line 93, in forward
output_l = self.main_decoder(self.encoder(x_l))
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/scuypers/CCT_4/models/encoder.py", line 60, in forward
x = self.base(x)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/container.py", line 141, in forward
input = module(input)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 446, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/nn/modules/conv.py", line 443, in _conv_forward
self.padding, self.dilation, self.groups)
RuntimeError: Given groups=1, weight of size [64, 4, 3, 3], expected input[2, 2000, 2000, 4] to have 4 channels, but got 2000 channels instead

In voc.py I have resized all images to (2000,2000) because I had many errors. I have stacked the RGB and altimetry together.
newSize = (2000,2000)

    alti = cv2.resize(alti, newSize)
    image = cv2.resize(image, newSize)
    label = cv2.resize(label, newSize)
    
    image_stack = np.dstack((image, alti))

If I don't resize:

0%| | 0/133 [00:00<?, ?it/s]image id, 44-2013-0280-6703-LA93-0M50-E080 image shape, (2001, 1999, 4) label shape, (2001, 1999)
image id, 44-2013-0284-6706-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0291-6721-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0287-6706-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0290-6715-LA93-0M50-E080 image shape, (2000, 1999, 4) label shape, (2000, 1999)
image id, 44-2013-0292-6723-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0296-6697-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0286-6707-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0281-6713-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0284-6708-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0292-6701-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0287-6712-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0293-6716-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0296-6721-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0286-6713-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0291-6700-LA93-0M50-E080 image shape, (2000, 2000, 4) label shape, (2000, 2000)
image id, 44-2013-0282-6712-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0285-6704-LA93-0M50-E080 image shape, (2001, 1999, 4) label shape, (2001, 1999)
image id, 44-2013-0292-6706-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0288-6700-LA93-0M50-E080 image shape, (2000, 2000, 4) label shape, (2000, 2000)
image id, 44-2013-0297-6709-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0294-6704-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0291-6713-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0286-6716-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
image id, 44-2013-0283-6703-LA93-0M50-E080 image shape, (2001, 2000, 4) label shape, (2001, 2000)
0%| | 0/133 [00:03<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 87, in
main(config, args.resume)
File "train.py", line 71, in main
trainer.train()
File "/home/scuypers/CCT_4/base/base_trainer.py", line 91, in train
results = self._train_epoch(epoch)
File "/home/scuypers/CCT_4/trainer.py", line 66, in _train_epoch
(input_l, target_l), (input_ul, target_ul) = next(dataloader), (None, None)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 521, in next
data = self._next_data()
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data
return self._process_data(data)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
data.reraise()
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/_utils.py", line 434, in reraise
raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch
return self.collate_fn(data)
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/_utils/collate.py", line 84, in default_collate
return [default_collate(samples) for samples in transposed]
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/_utils/collate.py", line 84, in
return [default_collate(samples) for samples in transposed]
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/_utils/collate.py", line 64, in default_collate
return default_collate([torch.as_tensor(b) for b in batch])
File "/home/scuypers/.conda/envs/envCCT/lib/python3.7/site-packages/torch/utils/data/_utils/collate.py", line 56, in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: stack expects each tensor to be equal size, but got [2001, 1999, 4] at entry 0 and [2001, 2000, 4] at entry 1

Do you understand these errors?

from cct.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.