Comments (9)
Hello, it seems that the code currently only works on grayscale images. II am interested in processing images with 3 channels (RGB). Has anyone already modified the code accordingly? What do I have to pay attention to?
@andife
Hello, this repo also supports RGB image with 3 channels.
The network is original support 3 channels input (See line 386-387 in vit_seg_modeling.py):
if x.size()[1] == 1:
x = x.repeat(1,3,1,1)
from transunet.
I have a question about running the code. Have you actually ran the code, I mean trained the model and tested the model on their images ? And did you get the same or similar results as in the their paper ?
Thanks
from transunet.
Hello,
it seems that I still have problems to prepare the dataset
So at least the class RandomGenerator cannot be used directly,
because of x, y = image.shape
ValueError: too many values to unpack (expected 2)
I tried the pipeline using it with RGB data, and get the following:
Traceback (most recent call last):
File "train.py", line 103, in <module>
trainer[dataset_name](args, net, snapshot_path)
File "project_TransUNet/TransUNet/trainer.py", line 133, in trainer_owndataset
for i_batch, sampled_batch in enumerate(trainloader):
File "anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
data = self._next_data()
File anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data
return self._process_data(data)
File anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
data.reraise()
File "anaconda3/lib/python3.8/site-packages/torch/_utils.py", line 394, in reraise
raise self.exc_type(msg)
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
data = fetcher.fetch(index)
File anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "project_TransUNet/TransUNet/datasets/dataset_owndataset.py", line 74, in __getitem__
sample = self.transform(sample)
File anaconda3/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 70, in __call__
img = t(img)
File project_TransUNet/TransUNet/datasets/dataset_owndataset.py", line 39, in __call__
x, y = image.shape
ValueError: too many values to unpack (expected 2)
from transunet.
Hello, it seems that the code currently only works on grayscale images. II am interested in processing images with 3 channels (RGB). Has anyone already modified the code accordingly? What do I have to pay attention to?
@andife
Hello, this repo also supports RGB image with 3 channels.The network is original support 3 channels input (See line 386-387 in vit_seg_modeling.py):
if x.size()[1] == 1:
x = x.repeat(1,3,1,1)
@Beckschen I'm trying to use this model for RGB images. I removed the random rotations (they seemed buggy for RGB images), and instead now get an error on the lines you have mentioned (386-387 in vit_seg_modeling.py
). The error is as follows:
RuntimeError: Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor
from transunet.
Hello,
Can someone point me to the solution?
Does one have working code?
Currently TransUnet expects/uses
shape x: torch.Size([12, 1, 224, 224])
for the synapse dataset.
When I tried to use my files with
RGB-Channel. I got
shape x: torch.Size([12, 1, 3, 736, 736])
Obviously, the dimensions did not fit
.
Think I have to get rid of the '1'
I squeezed the dataset, but then I got the following error:
Traceback (most recent call last):
File "train.py", line 114, in <module>
trainer[dataset_name](args, net, snapshot_path)
File "/home/andife/project_TransUNet/TransUNet/trainer.py", line 223, in trainer_ulm3D
outputs = model(image_batch)
File "/home/andife/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in __call__
result = self.forward(*input, **kwargs)
File "/home/andife/project_TransUNet/TransUNet/networks/vit_seg_modeling.py", line 393, in forward
x, attn_weights, features = self.transformer(x) # (B, n_patch, hidden)
File "/home/andife/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in __call__
result = self.forward(*input, **kwargs)
File "/home/andife/project_TransUNet/TransUNet/networks/vit_seg_modeling.py", line 254, in forward
embedding_output, features = self.embeddings(input_ids)
File "/home/andife/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in __call__
result = self.forward(*input, **kwargs)
File "/home/andife/project_TransUNet/TransUNet/networks/vit_seg_modeling.py", line 163, in forward
embeddings = x + self.position_embeddings
RuntimeError: The size of tensor a (2116) must match the size of tensor b (196) at non-singleton dimension 1
from transunet.
Hello, it seems that the code currently only works on grayscale images. II am interested in processing images with 3 channels (RGB). Has anyone already modified the code accordingly? What do I have to pay attention to?
@andife
Hello, this repo also supports RGB image with 3 channels.
The network is original support 3 channels input (See line 386-387 in vit_seg_modeling.py):
if x.size()[1] == 1:
x = x.repeat(1,3,1,1)@Beckschen I'm trying to use this model for RGB images. I removed the random rotations (they seemed buggy for RGB images), and instead now get an error on the lines you have mentioned (386-387 in
vit_seg_modeling.py
). The error is as follows:
RuntimeError: Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor
Did you fix this? I am also trying to repeat this for RGB images.
from transunet.
Hello, I have the same problem. Have you solved it?@Some1OutThere
from transunet.
Hello, it seems that I still have problems to prepare the dataset
So at least the class RandomGenerator cannot be used directly, because of x, y = image.shape ValueError: too many values to unpack (expected 2)
I tried the pipeline using it with RGB data, and get the following:
Traceback (most recent call last): File "train.py", line 103, in <module> trainer[dataset_name](args, net, snapshot_path) File "project_TransUNet/TransUNet/trainer.py", line 133, in trainer_owndataset for i_batch, sampled_batch in enumerate(trainloader): File "anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 345, in __next__ data = self._next_data() File anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data return self._process_data(data) File anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data data.reraise() File "anaconda3/lib/python3.8/site-packages/torch/_utils.py", line 394, in reraise raise self.exc_type(msg) ValueError: Caught ValueError in DataLoader worker process 0. Original Traceback (most recent call last): File "anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "project_TransUNet/TransUNet/datasets/dataset_owndataset.py", line 74, in __getitem__ sample = self.transform(sample) File anaconda3/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 70, in __call__ img = t(img) File project_TransUNet/TransUNet/datasets/dataset_owndataset.py", line 39, in __call__ x, y = image.shape ValueError: too many values to unpack (expected 2)
I have solved this issue. If the image is a RGB image, the image.shape would be a tuple like (h, w, 3), the original code
x, y = image.shape
is unpacking two elements, but image.shape has three elements. So you can fix it by changing the code like x, y, z = image.shape
.
from transunet.
Hello, it seems that the code currently only works on grayscale images. II am interested in processing images with 3 channels (RGB). Has anyone already modified the code accordingly? What do I have to pay attention to?
@andife
Hello, this repo also supports RGB image with 3 channels.
The network is original support 3 channels input (See line 386-387 in vit_seg_modeling.py):
if x.size()[1] == 1:
x = x.repeat(1,3,1,1)@Beckschen I'm trying to use this model for RGB images. I removed the random rotations (they seemed buggy for RGB images), and instead now get an error on the lines you have mentioned (386-387 in
vit_seg_modeling.py
). The error is as follows:
RuntimeError: Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor
Did you fix this? I am also trying to repeat this for RGB images.
Hello, I had the same problem when running test.py, did you solve it?
from transunet.
Related Issues (20)
- Different input size (width x height)
- Reason for [-125, 275] input clipping
- "ZeroDivisionError: integer division or modulo by zero" when vit_patches_size=8 HOT 3
- Need R50+ViT-B_16 rather than R50-ViT-B_16!
- 当我在运行TransUNet-main的train.py时出现错误:KeyError: 'Transformer/encoderblock_0/Multi5HeadDotProductAttention_1/query/kernel is not a file in the archive' 这是在我进行KeyError: 'Transformer/encoderblock_0/MultiHeadDotProductAttention_1/query\\kernel is not a file in the archive'后的更改出现的错误,csdn说这是os.path.join 合并路径的时候出现的问题,更改后仍然出现以上错误 HOT 4
- Even if we fix the seed, the results change for each training.
- asking for you help
- ACDC dataset 100 cases of data HOT 1
- Training for three-channel dataset
- Need R50+ViT-L_16 pretrained model rather than R50+ViT-L_32 HOT 1
- 导入包报错,文件夹重名导致的坑 HOT 2
- Data preprocessing HOT 2
- Training with different image size HOT 1
- Is the Synapse multi-organ segmentation dataset experimental result obtained from is the 20 samples official test set?
- change patch_size during test
- PreActBottleneck
- Training performance issues on small-sized targets
- The issue arises from the absence of the "lists_Synapse" folder.
- ACDC dataset HOT 1
- About the solution of problems like "have 3 channels, but got 1000 channels instead"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transunet.