Coder Social home page Coder Social logo

wkentaro / fcn Goto Github PK

View Code? Open in Web Editor NEW
218.0 15.0 98.0 20.46 MB

Chainer Implementation of Fully Convolutional Networks. (Training code to reproduce the original result is available.)

License: MIT License

Python 100.00%
computer-vision chainer deep-learning segmentation fcn convolutional-networks semantic-segmentation fcn8s

fcn's Introduction

fcn - Fully Convolutional Networks

PyPI Version Python Versions GitHub Actions

Chainer implementation of Fully Convolutional Networks.

Installation

pip install fcn

Inference

Inference is done as below:

# forwaring of the networks
img_file=https://farm2.staticflickr.com/1522/26471792680_a485afb024_z_d.jpg
fcn_infer.py --img-files $img_file --gpu -1 -o /tmp  # cpu mode
fcn_infer.py --img-files $img_file --gpu 0 -o /tmp   # gpu mode

Original Image: https://www.flickr.com/photos/faceme/26471792680/

Training

cd examples/voc
./download_datasets.py
./download_models.py

./train_fcn32s.py --gpu 0
# ./train_fcn16s.py --gpu 0
# ./train_fcn8s.py --gpu 0
# ./train_fcn8s_atonce.py --gpu 0

The accuracy of original implementation is computed with (evaluate.py) after converting the caffe model to chainer one using convert_caffe_to_chainermodel.py.
You can download vgg16 model from here: vgg16_from_caffe.npz.

FCN32s

Implementation Accuracy Accuracy Class Mean IU FWAVACC Model File
Original 90.4810 76.4824 63.6261 83.4580 fcn32s_from_caffe.npz
Ours (using vgg16_from_caffe.npz) 90.5668 76.8740 63.8180 83.5067 -

FCN16s

Implementation Accuracy Accuracy Class Mean IU FWAVACC Model File
Original 90.9971 78.0710 65.0050 84.2614 fcn16s_from_caffe.npz
Ours (using fcn32s_from_caffe.npz) 90.9671 78.0617 65.0911 84.2604 -
Ours (using fcn32s_voc_iter00092000.npz) 91.1009 77.2522 65.3628 84.3675 -

FCN8s

Implementation Accuracy Accuracy Class Mean IU FWAVACC Model File
Original 91.2212 77.6146 65.5126 84.5445 fcn8s_from_caffe.npz
Ours (using fcn16s_from_caffe.npz) 91.2513 77.1490 65.4789 84.5460 -
Ours (using fcn16s_voc_iter00100000.npz) 91.2608 78.1484 65.8444 84.6447 -

FCN8sAtOnce

Implementation Accuracy Accuracy Class Mean IU FWAVACC Model File
Original 91.1288 78.4979 65.3998 84.4326 fcn8s-atonce_from_caffe.npz
Ours (using vgg16_from_caffe.npz) 91.0883 77.3528 65.3433 84.4276 -

Left to right, FCN32s, FCN16s and FCN8s, which are fully trained using this repo. See above tables to see the accuracy.

License

See LICENSE.

Cite This Project

If you use this project in your research or wish to refer to the baseline results published in the README, please use the following BibTeX entry.

@misc{chainer-fcn2016,
  author =       {Ketaro Wada},
  title =        {{fcn: Chainer Implementation of Fully Convolutional Networks}},
  howpublished = {\url{https://github.com/wkentaro/fcn}},
  year =         {2016}
}

fcn's People

Contributors

kaleidoscopical avatar knorth55 avatar pazeshun avatar wkentaro avatar yuyu2172 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fcn's Issues

fcn16s model mean IU lower than fcn32s model

I'm training FCN16s using pretraind FCN-32s with meanIU ~57 %. The meanIU of FCN16s is 47 % after 100000 iterations. It is lower than meanIU of FCN-32s.
I'm using the following parameters.
・learning rate: 1e-10
・momentum: 0.99
・weight decay: 5e-4
also i notice #79 ,so i add some code. I copy the weight of pre-trained model (VGG) to FCN32s
for link_name in ['fc6', 'fc7']: W1, b1 = getattr(vgg, link_name).params() W2, b2 = getattr(model, link_name).params() W2.data = W1.data.reshape(W2.shape) b2.data = b1.data
But FCN-16s is lower than meanIU of FCN-32s.

how to get feature map ?

I want to get intermediate layers, like conv_1, conv_2, feature map for visualization. So what should I do?

Training on variable input size

First of all thanks for the code, I´m new to Chainer and I find the code very clean.

I´m going to try to use FCN for a segmentation problem but I have one doubt from the code. In the FCN32 model, after the Deconvolution2D there is a hardcoded crop.

h = self.upscore(score_fr)
h = h[:, :, 19:19 + x.data.shape[2], 19:19 + x.data.shape[3]]

This crop is due to a particular size for the training set, right?

Cannot download Pre-trained Model

Hi, is there a way to download the pre-trained model because when I tried to use fcn.models.FCN8s.download() it has a gdown error such as below

gdown.exceptions.FileURLRetrievalError: Failed to retrieve file url:

    Cannot retrieve the public link of the file. You may need to change
    the permission to 'Anyone with the link', or have had many accesses.
    Check FAQ in https://github.com/wkentaro/gdown?tab=readme-ov-file#faq.

You may still be able to access the file from the browser:

but Gdown can't. Please check connections and permissions.

I have tried to open the link but it was not found

Thank you

Can't run pascal example

when trying to run fcn/examples/pascal/train_fcn32s.py, the program fails at the download_vgg16_chainermodel() function, probably because the program gdown is not found. I cannot find any information about gdown, how can I get it? Thanks!

Doubts with the cropping after deconv

Hey @wkentaro, I still have a doubt regarding the cropping performed after the transposed convolution. It's more of a conceptual doubt than code itself but maybe some other people might benefit from this doubt.

In the gist that you provided in the other issue I opened regarding the cropping I understand that after a x32 downsample, when upsampling, depending on the input size there might be an offset (if the size is not divisible by 32) and that's the reason of the cropping. Initially I thought that if I want to train with variable input sizes I have to modify that cropping to match the corresponding offset for that size.

I tried infering images from my dataset using the infer.py code but I realized that checking the size of the prediction it matches the input size for different sizes, while I was expecting a different size. Shouldn't I modify the offset accordingly and why is the output matching the input size with a fixed crop of 19? I would highly appreciate if you could help me solving this doubt.

Thanks again!

Binary Training

I'm trying to change your code for a binary problem.
After I train and use the new model get the following result in one of the test images
image-179
Do you have any clue why the predicted image have that resolution issue in the labels box.
And why i get that red noise when i look in the prediction i don't get any positive so there is no reason for that points.

Download script for datasets fail to cover all datasets used in voc example

Hi,

I'm re-posting here Issue #98 which is still unsolved:

Here is a summary of what I'm facing:

  1. I have read the readme already.

  2. I downloaded FCN as mentioned: pip install fcn and it worked well.

  3. Inference worked perfectly.

  4. However, training is not working for me. Here is what I did:
    (a) Downloaded dataset using: ./download_dataset.py
    (b) Downloaded models using: ./download_models.py
    (c) Attempted training using: ./train_fcn*s.py --gpu -0 however it failed! Here is the error message:

    IOError: [Errno 2] No such file or directory: '~/data/datasets/VOC/benchmark_RELEASE/dataset/train.txt'

  5. Also evaluation didn't work! I did it as described in the readme:
    ./evaluate.py ~data/models/chainer/fcn8s_from_caffe.npz
    Here is the error message:
    IOError: [Errno 2] No such file or directory: '~data/datasets/VOC/VOCdevkit/VOC2011/ImageSets/Segmentation/train.txt'

What's going on? I appreciate your help.

And please don't close this issue too soon this time!

Thanks!

Can't do training!

Hi Kentaro,

Training is not working for me. Whenever I run ./examples/voc/train_fcn*s.py --gpu 0, I get the following error message:

IOError: [Errno 2] No such file or directory: '~data/models/chainer/fcn16s_from_caffe.npz'

Why does it assume that data and models exists on this path '~data/models/chainer/ ?

I desperately created this folder and put .npz file there but still it didn't work.

Any help is appreciated!

Thanks!

what is your "fcn.data_dir"

hi, i cloned your repository, but there are some problems, have you tested your code?
i used pip to install on my pc, using commond "pip install fcn"
followed your instruction, first i should convert caffe model to chainer model, with "./scripts/caffe_to_chainermodel.py ", but i got some wrong message
`/usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
/usr/local/lib/python2.7/dist-packages/matplotlib/init.py:1350: UserWarning: This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called before pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

warnings.warn(_use_error_msg)
Traceback (most recent call last):
File "./scripts/caffe_to_chainermodel.py", line 64, in
main()
File "./scripts/caffe_to_chainermodel.py", line 58, in main
caffemodel = fcn.setup.download_fcn8s_caffemodel()
File "/usr/local/lib/python2.7/dist-packages/fcn/setup.py", line 41, in download_fcn8s_caffemodel
url=open(url_file).read().strip(),
IOError: [Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/fcn/_data/fcn.berkeleyvision.org/voc-fcn8s/caffemodel-url'
`
it sounds the "fcn.data_dir" is "/usr/local/lib/python2.7/dist-packages/fcn/_data/"
but when i use ipython to debug this problem. In first console window, i typed "import fcn; fcn.data_dir", i got the answer "/home/work-station/zx/fcn/data"; But when i opened another console window, i got an answer "/usr/local/lib/python2.7/dist-packages/fcn/_data", it doesn't make sense

what should i do now, thanks

infer.py can not produce test result?

When I use FCN32s_model_iter_xxx.h5 to test image, everything is ok. However, when using FCN16s_model_iter_xxx.h5 in "infer.py":

if osp.basename(chainermodel).lower().startswith('fcn32s'):
    model_class = fcn.models.FCN32s
elif osp.basename(chainermodel).lower().startswith('fcn16s'):
    model_class = fcn.models.FCN16s
elif osp.basename(chainermodel).lower().startswith('fcn8s'):
    model_class = fcn.models.FCN8s
else:
    raise ValueError
model = model_class(n_class=len(dataset.label_names))
chainer.serializers.load_hdf5(chainermodel, model)

infer = fcn.Inferencer(dataset, model, gpu)
for img_file in img_files:
    img, label = infer.infer_image_file(img_file)
    out_img = infer.visualize_label(img, label)

    out_file = osp.join(save_dir, osp.basename(img_file))
    scipy.misc.imsave(out_file, out_img)
    print('- out_file: {0}'.format(out_file))

error occurs:

File "", line 48, in main
img, label = infer.infer_image_file(img_file['img'])

File "/home/dxiaosa/anaconda2/lib/python2.7/site-packages/fcn/inferencer.py", line 43, in infer_image_file
label = self.infer(x)

File "/home/dxiaosa/anaconda2/lib/python2.7/site-packages/fcn/inferencer.py", line 26, in infer
self.model(x)

File "/home/dxiaosa/anaconda2/lib/python2.7/site-packages/fcn/models/fcn16s.py", line 145, in call
self.loss = F.softmax_cross_entropy(self.score, t, normalize=False)

File "/home/dxiaosa/anaconda2/lib/python2.7/site-packages/chainer-1.18.0-py2.7-linux-x86_64.egg/chainer/functions/loss/softmax_cross_entropy.py", line 169, in softmax_cross_entropy
return SoftmaxCrossEntropy(use_cudnn, normalize, cache_score)(x, t)

File "/home/dxiaosa/anaconda2/lib/python2.7/site-packages/chainer-1.18.0-py2.7-linux-x86_64.egg/chainer/function.py", line 182, in call
for x in inputs]

File "/home/dxiaosa/anaconda2/lib/python2.7/site-packages/chainer-1.18.0-py2.7-linux-x86_64.egg/chainer/variable.py", line 95, in init
raise TypeError(msg)

TypeError: numpy.ndarray or cuda.ndarray are expected.
Actual: <type 'NoneType'>

How can i do? thx.

How to get training feature maps?

Last time, we resolved the problem of fetching the feature maps off line, ie. in testing program. So, if I want to get the feature maps when training, how can I do? Thx.

Fowarding Test

I'm trying to run the Forwarding example but I get this error:
seleccion_006

Almost all IU show "NaN"

I'm investigating IU of each class in trained FCN16s. In order to output each IU, I rewrote label_accuracy_score in utils.py as follows ("iu" is added to "return") ;


def label_accuracy_score(label_true, label_pred, n_class):
hist = _fast_hist(label_true.flatten(), label_pred.flatten(), n_class)
acc = np.diag(hist).sum() / hist.sum()
acc_cls = np.diag(hist) / hist.sum(axis=1)
acc_cls = np.nanmean(acc_cls)
iu = np.diag(hist) / (hist.sum(axis=1) + hist.sum(axis=0) - np.diag(hist))
mean_iu = np.nanmean(iu)
freq = hist.sum(axis=1) / hist.sum()
fwavacc = (freq[freq > 0] * iu[freq > 0]).sum()
return acc, acc_cls, mean_iu, fwavacc, iu


Then, I outputted iu[0], iu[1], .... ,iu[20]. Hoverer, almost all IU shew "NaN".
Do you happen to have any knowledge about this cause? If you find out this cause, please tell me.

Unable to run caffe_to_chainernodel.py

Hi, when I run the ./caffe_to_chainermodel.py, the errror gives: No such file or directory: '~/data/models/chainer/fcn8s_from_caffe.npz. I am not sure if you did have a directory called "data" before in this fcn repository? Thank you in advance for the help

Permission denied when installing fcn on Ubuntu

Traceback (most recent call last):
  File "/home/wkentaro/ros/indigo/src/jsk-ros-pkg/jsk_recognition/jsk_perception/node_scripts/fcn_object_segmentation.py", line 10, in <module>
    import fcn
  File "/usr/local/lib/python2.7/dist-packages/fcn/__init__.py", line 5, in <module>
    import fcn.setup
  File "/usr/local/lib/python2.7/dist-packages/fcn/setup.py", line 20, in <module>
    data_dir = _get_data_dir()
  File "/usr/local/lib/python2.7/dist-packages/fcn/setup.py", line 16, in _get_data_dir
    os.makedirs(data_dir)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/fcn/_data'

I want to train my datasets but get the following errors, what should I do?

(tet-fcn) pu@pu:~/Downloads/tet-fcn/fcn/examples/voc$ ./train_fcn32s.py --gpu 0
/home/pu/Downloads/tet-fcn/local/lib/python2.7/site-packages/cupy/core/fusion.py:659: FutureWarning: cupy.core.fusion is experimental. The interface can change in the future.
util.experimental('cupy.core.fusion')
/home/pu/Downloads/tet-fcn/local/lib/python2.7/site-packages/chainer-4.0.0b2-py2.7.egg/chainer/backends/cuda.py:88: UserWarning: cuDNN is not enabled.
Please reinstall CuPy after you install cudnn
(see https://docs-cupy.chainer.org/en/stable/install.html#install-cupy-with-cudnn-and-nccl).
'cuDNN is not enabled.\n'
train: 0%| | 0/100000 [00:00<?, ?it/s]Exception in thread prefetch_loop:[iteration=00000000]: 0%| | 0/736 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/pu/Downloads/tet-fcn/local/lib/python2.7/site-packages/chainer-4.0.0b2-py2.7.egg/chainer/iterators/multiprocess_iterator.py", line 330, in _run
alive = self._task()
File "/home/pu/Downloads/tet-fcn/local/lib/python2.7/site-packages/chainer-4.0.0b2-py2.7.egg/chainer/iterators/multiprocess_iterator.py", line 349, in _task
data_all = future.get(_response_time)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 567, in get
raise self._value
IOError: [Errno 2] No such file or directory: '/home/pu/data/datasets/VOC/VOCdevkit/VOC2012/JPEGImages/2007_000033.jpg'

How to train our own datasets

hi, sorry to interrupt you again.
I want to train my own datasets(just 2 classes), i think i have changed all the code that needs to be changed, but there are still some problems, can you give an instruction on how to train my own datasets? Thanks
train_error

Loss does not drop. IndexError: index 19 is out of bounds for axis 0 with size 5

First thank you for your excellent code. I am a beginner of FCN and Chainer.
I have run the code on the examples, now I am trying to train FCN32s on my own dataset, but I have met some problems. First the loss does not drop,it seems that the network does not converge, second I always met the following error and I don't know how to fix it.

Exception in main training loop: index 19 is out of bounds for axis 0 with size 5
Traceback (most recent call last):
File "/home/nicci/FCN/wkentaro-test2/lib/python3.6/site-packages/chainer/training/trainer.py", line 318, in run
entry.extension(self)
File "/home/nicci/FCN/wkentaro-test2/lib/python3.6/site-packages/fcn/extensions/semantic_segmentation_vis_report.py", line 54, in call
lt, im, label_names=self._class_names)
File "/home/nicci/FCN/wkentaro-test2/lib/python3.6/site-packages/fcn/utils.py", line 262, in label2rgb
lbl_viz = cmap[lbl]
Will finalize trainer extensions and updater before reraising the exception.
Traceback (most recent call last):
File "train_fcn32s.py", line 145, in
main()
File "train_fcn32s.py", line 141, in main
trainer.run()
File "/home/nicci/FCN/wkentaro-test2/lib/python3.6/site-packages/chainer/training/trainer.py", line 329, in run
six.reraise(*sys.exc_info())
File "/home/nicci/FCN/wkentaro-test2/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/home/nicci/FCN/wkentaro-test2/lib/python3.6/site-packages/chainer/training/trainer.py", line 318, in run
entry.extension(self)
File "/home/nicci/FCN/wkentaro-test2/lib/python3.6/site-packages/fcn/extensions/semantic_segmentation_vis_report.py", line 54, in call
lt, im, label_names=self._class_names)
File "/home/nicci/FCN/wkentaro-test2/lib/python3.6/site-packages/fcn/utils.py", line 262, in label2rgb
lbl_viz = cmap[lbl]
IndexError: index 19 is out of bounds for axis 0 with size 5

My image size is 500*500 (5 classes)
And I also want to know if I train on my own dataset,where should I need to modify?(which python file)Thanks for your answer.

Type in example train

in examples/apc2016/apc2016.py lines 80 and 108, paths to data should be sufixed with _sample

how to implement fcn with chainer

Hi, me again! I'm new to image segmentation.I want to try chainer this time.
But I don't know the relationship between this fcn folder and chainer.
Do I need to install chainer first?
Should this fcn be put into chainer foler or somewhere?
And how to set the PYTHONPATH?

Thanks a lot!!!

GPU use check in Inferencer seems incorrect

Hi, thanks for sharing fcn with chainer code!

I found a possible bug, in Inference.infer_image_file,
in this method gpu availability is check with:

if self.gpu >= -1:

, but I wonder this should be:

if self.gpu > -1:

If self.gpu is checked with self.gpu >= -1, input data is translated into cuda
even with cpu mode params like

fcn_infer.py --img-files sample.jpg --gpu -1  # cpu mode

If this is not a bug, but a intentional code, sorry and just ignore this issue.

How to install fcn in anaconda environment?

Thanks for providing the implementation. It is a dependency of fcn-pytorch and I use anaconda. The instruction only give pip installation guide. I want to know how to install in conda.

Learnable Deconvolution weights question

Hello wkentaro,

One more time, thank you for your awesome contribution. I have a question regarding the upsampling in your implementation. Even though the Deconvolution2D links are initialized with weights, all of them are learnable and don't have the weights fixed, right?

Unable to run the new train_fcn32s

I have got this error when I was trying to run the new train_fcn32s.

/usr/local/lib/python2.7/dist-packages/cupy/core/fusion.py:659: FutureWarning: cupy.core.fusion is experimental. The interface can change in the future.
  util.experimental('cupy.core.fusion')
# -----------------------------------------------------------------------------
{'gpu': 0,
 'interval_eval': 4000,
 'interval_print': 20,
 'lr': 1e-10,
 'max_iteration': 100000,
 'model': 'FCN32s',
 'momentum': 0.99,
 'out': '/root/fcn/juanjo_fcn/examples/voc/logs/20180131_075839',
 'timestamp': '2018-01-31T07:58:39.807105',
 'weight_decay': 0.0005}
# -----------------------------------------------------------------------------
Exception in main training loop: Unsupported dtype object
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/trainer.py", line 304, in run
    update()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/updaters/standard_updater.py", line 149, in update
    self.update_core()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/updaters/standard_updater.py", line 154, in update_core
    in_arrays = self.converter(batch, self.device)
  File "/usr/local/lib/python2.7/dist-packages/chainer/dataset/convert.py", line 110, in concat_examples
    return to_device(device, _concat_arrays(batch, padding))
  File "/usr/local/lib/python2.7/dist-packages/chainer/dataset/convert.py", line 36, in to_device
    return cuda.to_gpu(x, device)
  File "/usr/local/lib/python2.7/dist-packages/chainer/backends/cuda.py", line 277, in to_gpu
    return _array_to_gpu(array, device_, stream)
  File "/usr/local/lib/python2.7/dist-packages/chainer/backends/cuda.py", line 322, in _array_to_gpu
    return cupy.asarray(array)
  File "/usr/local/lib/python2.7/dist-packages/cupy/creation/from_data.py", line 61, in asarray
    return core.array(a, dtype, False)
  File "cupy/core/core.pyx", line 2085, in cupy.core.core.array
  File "cupy/core/core.pyx", line 2116, in cupy.core.core.array
Will finalize trainer extensions and updater before reraising the exception.
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/root/fcn/juanjo_fcn/examples/voc/train_fcn32s.py", line 144, in <module>
    main()
  File "/root/fcn/juanjo_fcn/examples/voc/train_fcn32s.py", line 140, in main
    trainer.run()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/trainer.py", line 318, in run
    six.reraise(*sys.exc_info())
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/trainer.py", line 304, in run
    update()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/updaters/standard_updater.py", line 149, in update
    self.update_core()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/updaters/standard_updater.py", line 154, in update_core
    in_arrays = self.converter(batch, self.device)
  File "/usr/local/lib/python2.7/dist-packages/chainer/dataset/convert.py", line 110, in concat_examples
    return to_device(device, _concat_arrays(batch, padding))
  File "/usr/local/lib/python2.7/dist-packages/chainer/dataset/convert.py", line 36, in to_device
    return cuda.to_gpu(x, device)
  File "/usr/local/lib/python2.7/dist-packages/chainer/backends/cuda.py", line 277, in to_gpu
    return _array_to_gpu(array, device_, stream)
  File "/usr/local/lib/python2.7/dist-packages/chainer/backends/cuda.py", line 322, in _array_to_gpu
    return cupy.asarray(array)
  File "/usr/local/lib/python2.7/dist-packages/cupy/creation/from_data.py", line 61, in asarray
    return core.array(a, dtype, False)
  File "cupy/core/core.pyx", line 2085, in cupy.core.core.array
  File "cupy/core/core.pyx", line 2116, in cupy.core.core.array
ValueError: Unsupported dtype object

I'm using Chainer and CuPy from master branch. Which Chainer version are you using?
(requirements.txt specified only chainer>=2.0.0)

fcn32.py "value error"

hi,when I try to change pascal.py
target_names = np.array([ 'background', 'newtarget', ])
and I reference my VOC2012's segmentation,I prepare some png like this,but can not have the correct result.

Training from scratch

Sorry, am kinda new to FCN.
Why we are using pretrained model, can we train from scratch on cusrom dataset in scripts/fcn_train.py?

thanks,

Alex.

question!,help!

Hello, read your code, don't know how to use your code is, oneself also in the study of FCN,Specific how to use the code.than you for you research!

About the background color

In color map the (0,0,0) means black, can you tell me how to express the color of your background in colour map?

typo in setup

should be os.environ['FCN_DATA'] instead os.environ('FCN_DATA')

in fcn/fcn/setup.py 22

OutOfMemoryError when trying to train FCN32s on my own dataset

I am trying to train FCN32s on my own dataset. The training set consists of 135 images. The image size would be 1600x1200, 1280x960, and 1024x768. In train_fcn32s.py, I use the original shared_mem value which is 10 ** 7 for chainer.iterators.MultiprocessIterator.

    iter_train = chainer.iterators.MultiprocessIterator(
        dataset_train, batch_size=1, shared_mem=10 ** 7)

But I have this warning message:

Please set shared_mem option for MultiprocessIterator.
Expect shared memory size: 12000000 bytes.
Actual shared memory size: 1000000 bytes.

And this error message:

train:   7%|##5                               | 74/1000 [01:37<20:20,  1.32s/it]Traceback (most recent call last):
  File "train_fcn32s.py", line 96, in <module>
    main()
  File "train_fcn32s.py", line 92, in main
    trainer.train()
  File "/usr/local/lib/python2.7/dist-packages/fcn/trainer.py", line 198, in train
    loss.backward()
  File "/usr/local/lib/python2.7/dist-packages/chainer/variable.py", line 878, in backward
    self._backward_main(retain_grad)
  File "/usr/local/lib/python2.7/dist-packages/chainer/variable.py", line 979, in _backward_main
    target_input_indexes, out_grad, in_grad)
  File "/usr/local/lib/python2.7/dist-packages/chainer/function_node.py", line 514, in backward_accumulate
    gxs = self.backward(target_input_indexes, grad_outputs)
  File "/usr/local/lib/python2.7/dist-packages/chainer/functions/activation/relu.py", line 49, in backward
    return ReLUGrad2(y).apply((gy[0],))
  File "/usr/local/lib/python2.7/dist-packages/chainer/function_node.py", line 245, in apply
    outputs = self.forward(in_data)
  File "/usr/local/lib/python2.7/dist-packages/chainer/function_node.py", line 337, in forward
    return self.forward_gpu(inputs)
  File "/usr/local/lib/python2.7/dist-packages/chainer/functions/activation/relu.py", line 80, in forward_gpu
    'relu_bwd')(self.b, inputs[0])
  File "cupy/core/elementwise.pxi", line 566, in cupy.core.core.ElementwiseKernel.__call__
  File "cupy/core/elementwise.pxi", line 409, in cupy.core.core._get_out_args_with_params
  File "cupy/core/core.pyx", line 95, in cupy.core.core.ndarray.__init__
  File "cupy/cuda/memory.pyx", line 441, in cupy.cuda.memory.alloc
  File "cupy/cuda/memory.pyx", line 915, in cupy.cuda.memory.MemoryPool.malloc
  File "cupy/cuda/memory.pyx", line 936, in cupy.cuda.memory.MemoryPool.malloc
  File "cupy/cuda/memory.pyx", line 693, in cupy.cuda.memory.SingleDeviceMemoryPool.malloc
  File "cupy/cuda/memory.pyx", line 748, in cupy.cuda.memory.SingleDeviceMemoryPool._malloc
cupy.cuda.memory.OutOfMemoryError: out of memory to allocate 955444224 bytes (total 11433940992 bytes)

My GPU is NVIDIA 1080 Ti with 11 GB memory but the training process consume all of its memory. I have tried to increase the shared_mem value but I still get the same memory allocation issue. Could you please give me an idea about this issue? Or how should I properly configure the shared_mem value?

Test error

hi, i successfully trained my own datasets with fcn32s model, my data has only two class(background+another one) and i used only 140 images to train my own model, i just want to see the result first.
But with the test image, i got the answer: backround ~= 100%, all is background. I don't know why, maybe a small dataset or other something.
I have some questions:

  1. How to distinguish the category of your training image area? I mean in segmentclass image, how to recognize the area with red color is a cat not a pig
  2. Because i have just two class, so what is the impact of small data sets on the final outcome? very low accuracy?

Thank you very much!

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.