divamgupta / image-segmentation-keras

Implementation of Segnet, FCN, UNet , PSPNet and other models in Keras.
https://divamgupta.com/image-segmentation/2019/06/06/deep-learning-semantic-segmentation-keras.html
MIT License
2.92k stars 1.16k forks source link

multiclass segmentation using unet and unet_mini #104

Open jaigsingla opened 5 years ago

jaigsingla commented 5 years ago

Hi,

Attempted multiclass segmentation using unet , it say model trained to 1 after epoch 10 but predictions are not that sharp. ??

second thing is i want to change color of predicted classes . how to do that?

Tried to use unet_mini also, after training while predicting it says you are trying to load weight file containing 17 layers in to model with 11 layers?

divamgupta commented 5 years ago

To change the color you might want to modify this line.

Please share the stack trace and the code/commands to reproduce the error you are getting.

jaigsingla commented 5 years ago

Traceback (most recent call last):

File "/home/deep/anaconda3/envs/ml/lib/python3.6/runpy.py", line 193, in _run_module_as_main

"__main__", mod_spec)

File "/home/deep/anaconda3/envs/ml/lib/python3.6/runpy.py", line 85, in _run_code

exec(code, run_globals)

File "/home/deep/anaconda3/envs/ml/lib/python3.6/site-packages/keras_segmentation-0.2.0-py3.6.egg/keras_segmentation/main.py", line 4, in

File "/home/deep/anaconda3/envs/ml/lib/python3.6/site-packages/keras_segmentation-0.2.0-py3.6.egg/keras_segmentation/cli_interface.py", line 134, in main

File "/home/deep/anaconda3/envs/ml/lib/python3.6/site-packages/keras_segmentation-0.2.0-py3.6.egg/keras_segmentation/cli_interface.py", line 92, in cli_predict

File "/home/deep/anaconda3/envs/ml/lib/python3.6/site-packages/keras_segmentation-0.2.0-py3.6.egg/keras_segmentation/predict.py", line 86, in predict_multiple

File "/home/deep/anaconda3/envs/ml/lib/python3.6/site-packages/keras_segmentation-0.2.0-py3.6.egg/keras_segmentation/predict.py", line 35, in model_from_checkpoint_path

File "/home/deep/anaconda3/envs/ml/lib/python3.6/site-packages/keras/engine/network.py", line 1166, in load_weights

f, self.layers, reshape=reshape)

File "/home/deep/anaconda3/envs/ml/lib/python3.6/site-packages/keras/engine/saving.py", line 1030, in load_weights_from_hdf5_group

str(len(filtered_layers)) + ' layers.')

ValueError: You are trying to load a weight file containing 17 layers into a model with 11 layers.

divamgupta commented 5 years ago

Could you also give the exact set of commands you used.

jaigsingla commented 5 years ago

python -m keras_segmentation train \ --checkpoints_path="path_to_checkpoints" \ --train_images="dataset1/images_prepped_train/" \ --train_annotations="dataset1/annotations_prepped_train/" \ --val_images="dataset1/images_prepped_test/" \ --val_annotations="dataset1/annotations_prepped_test/" \ --n_classes=4 \ --input_height=512 \ --input_width=512 \ --model_name="unet_mini"\ --epochs=20

even tried with --model_name=vgg_unet; while predict command , error is seen. error in this case is trying to load a weight file containing 17 layers into a model with 19 layers.

divamgupta commented 5 years ago

this error could come if you used the same checkpoints path for two diffrent models. Please make sure you use a diffrent checkpoints_path for each model you use.

jaigsingla commented 5 years ago

Correct. its working fine for different checkpoint path. I want to print training accuracy as well as test accuracy . how to do this ?