Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with training.py #2

Open
chloeahampton opened this issue Aug 31, 2018 · 1 comment
Open

Problems with training.py #2

chloeahampton opened this issue Aug 31, 2018 · 1 comment

Comments

@chloeahampton
Copy link

chloeahampton commented Aug 31, 2018

Hello,
I tried using pixel-decoder as you suggested in the readme file, however I am having problems with training my dataset. I use: train.train(batch_size=4, imgs_folder=imgs, masks_folder=masks, models_folder=models, model_id='resnet_unet', origin_shape_no=256, border_no=32) where imgs and masks are directories for label-maker data. However, after generating the first batch of results, I get the following ValueError: Cannot feed value of shape (4, 256, 256, 3, 1) for Tensor 'conv2d_22_target:0', which has shape '(?, ?, ?, ?)'.

From the Traceback, I believe this comes from the first instance of fit_generator, on lines 66-70. Specifically, the traceback points to line 70, the callback.

这个项目很好, 我很高兴!

@Geoyi
Copy link
Owner

Geoyi commented Sep 1, 2018

哈哈,谢谢你的赞赏, @chloe-hampton。

The error comes from the labels. Label Maker creates 3 color channel labels for preview purpose, and you have to reshape the numpy array from (256, 256, 3) to (256, 256). I added utility script to convert it, see the script in this jupyter notebook I prepared for a conference.

In short, you can directly do:

from os import makedirs, path as op
from PIL import Image
import numpy as np

labels = np.load('labels.npz')

for label in labels.files:
    new_label_dir = op.join(os.getcwd(), "new_labels")
    if not op.isdir(new_label_dir):
        makedirs(new_label_dir)
    img = Image.fromarray(labels[label])
    print('Writing {}'.format(label))
    img.save('{}/{}.png'.format(new_label_dir, label))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants