Comments (9)
Are your images in dir_img
in colors (RGB) ? It seems that after the loading the images don't have 3 dimensions. Can you check the shape of im
?
from pytorch-unet.
my pictures are all black and white but I am not sure if they are formatted as RGB
from pytorch-unet.
that's the problem, I think they are loaded with only 1 channel so the shape is HxW where it should be CxHxW. You can try to change the code you mentionned to return np.expand_dims(np.array(im),axis=2), np.array(mask)
.
And if you haven't, you need to change n_channels to 1 in the UNet creation.
from pytorch-unet.
Made the changes you mentioned and still am getting
Starting training:
Epochs: 5
Batch size: 10
Learning rate: 0.1
Training size: 1900
Validation size: 100
Checkpoints: True
CUDA: True
Starting epoch 1/5.
Traceback (most recent call last):
File "train.py", line 139, in
img_scale=args.scale)
File "train.py", line 64, in train_net
for i, b in enumerate(batch(train, batch_size)):
File "/home/users/rssadre/RAPIDS-IDREAM/Pytorch-UNet/utils/utils.py", line 37, in batch
for i, t in enumerate(iterable):
File "/home/users/rssadre/RAPIDS-IDREAM/Pytorch-UNet/utils/utils.py", line 17, in hwc_to_chw
return np.transpose(img, axes=[2, 0, 1])
File "/home/users/rssadre/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 639, in transpose
return _wrapfunc(a, 'transpose', axes)
File "/home/users/rssadre/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 56, in _wrapfunc
return getattr(obj, method)(*args, **kwds)
ValueError: axes don't match array
from pytorch-unet.
In the hwc_to_chw
function before the line 17, can you print the shape of img
(img.shape
) and give it to me ? It should have 3 dimensions, no less.
from pytorch-unet.
@milesial Hi, thanks for sharing. My image shape is H × W, how should I modify the code?
from pytorch-unet.
@milesial I added img = np.reshape(img,img.shape+(1,))
in hwc_to_chw(), the error disappeared, but I don't know if it really solved the problem
from pytorch-unet.
Your image should be H x W * C, with C a "dummy" dimension in your case because there is only one channel. The code you cited adds this dimension so it should be OK now.
from pytorch-unet.
hello, I have the same problem with you. My dataset is also the same with you . And I modify the mode as your discussion above. But I get the problem
Starting training:
Epochs: 5
Batch size: 10
Learning rate: 0.1
Training size: 2204
Validation size: 116
Checkpoints: True
CUDA: True
Starting epoch 1/5.
(200, 125, 1)
(197, 125, 1)
(197, 125, 1)
(200, 125, 1)
(200, 125, 1)
(197, 125, 1)
(197, 125, 1)
(197, 125, 1)
(200, 125, 1)
(200, 125, 1)
Traceback (most recent call last):
File "train.py", line 141, in
img_scale=args.scale)
File "train.py", line 67, in train_net
imgs = np.array([i[0] for i in b]).astype(np.float32)
ValueError: could not broadcast input array from shape (200,125) into shape (1)
How should I deal with these?
Thank you.
from pytorch-unet.
Related Issues (20)
- Refer the datasets to download from Kaggle
- Windows .bat setup script HOT 1
- Latest Python versions have deprecated `distutils` module
- How to accurately calculate Model Parameters and GFLOPs?
- thanks a lot, your model help me lot, I make a grad-cam to mark what place the U-Net look, also named hot-map HOT 1
- The training loss is always nan. HOT 3
- dice = ? 0.5
- miou and acc
- 为什么预测出来的图片全黑,能不能回复一下 HOT 3
- can't change batch_size
- IndexError: list index out of range
- Python version HOT 1
- My own dataset reported an error
- Did you use "crop" in the skip connection? or you just connect them? HOT 1
- train error
- wandb issue HOT 3
- Trained Check Points not Working HOT 1
- about export pth to onnx
- what does n_classes=1 mean?
- A confusion in hubconf.py
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 pytorch-unet.