Giter VIP home page Giter VIP logo

Comments (28)

bonlime avatar bonlime commented on August 27, 2024 1

@bhack you're right, the model is really big. On my 1080ti it is possible to train only with a batch size of 6 images.
Yeah, it can make sense to freeze low-level features. Adding only ImageNet pre-trained xception is already in my checklist

from keras-deeplab-v3-plus.

bonlime avatar bonlime commented on August 27, 2024

from model import Deeplabv3
deeplab_model = Deeplabv3((512,512,3), num_classes=4, last_activation=True, OS=16)
deeplab_model.load_weights('deeplabv3_weights_tf_dim_ordering_tf_kernels.h5', by_name = True)

after that, you will have a usual Keras model, which you can train using fit, or fit_generator
if you want more detailed description, google any Keras tutorials
There are few important moments with this model:

  1. It is important to have a big batch to train BN layers properly, in order to do that you can train with OS 16 and inference with OS 8
  2. you can also freeze first 356 layers and train only decoder with big batch size first, then unfreeze all layers and train with smaller batch size

from keras-deeplab-v3-plus.

Soulempty avatar Soulempty commented on August 27, 2024

Can you give some advice on how to train on a new image datasets?I want to finetune with the pretrained model (cityscapes).

from keras-deeplab-v3-plus.

kli017 avatar kli017 commented on August 27, 2024

I try to initial the model by
deeplab_model = Deeplabv3((512,512,3), num_classes=4, last_activation=True, OS=16)
by the get below error
TypeError: Deeplabv3() got an unexpected keyword argument 'num_classes'

from keras-deeplab-v3-plus.

bonlime avatar bonlime commented on August 27, 2024

@kli017 interface changed a little bit. Look at the new one in README

from keras-deeplab-v3-plus.

kli017 avatar kli017 commented on August 27, 2024

@bonlime Thanks! The new one in README has a parameter named 'weighs' , however in the model.py the parameter is 'weights'. I tried both of them but still get error

deeplab_model = Deeplabv3((960,1440,3), classes=4, weighs = None, OS=16)
TypeError: Deeplabv3() got an unexpected keyword argument 'weighs'

from keras-deeplab-v3-plus.

bonlime avatar bonlime commented on August 27, 2024

Sorry, it was typo. Correct version is "weights", you should have problems with it

from keras-deeplab-v3-plus.

kli017 avatar kli017 commented on August 27, 2024

Hello, I also tried 'weights' with both None and 'pascal_voc'. But still got TypeError...
TypeError: Deeplabv3() got multiple values for keyword argument 'weights'

from keras-deeplab-v3-plus.

raghavmallick avatar raghavmallick commented on August 27, 2024

@kli017 Try using the arguments in the following format:

Deeplabv3(weights='pascal_voc', input_tensor=None, input_shape=(512, 512, 3), classes=21, OS=16)

This worked for me

from keras-deeplab-v3-plus.

bonlime avatar bonlime commented on August 27, 2024

@kli017 the reason why you get TypeError is because you pass input_shape as first argument without explicitly naming it. all parameters you pass into this model have to be named

from keras-deeplab-v3-plus.

bhack avatar bhack commented on August 27, 2024

@bonlime What is the memory requirements to train with the standard input and batch size? The full trainabile end to end (encoder+decoder) model seems quite big to fit in memory.

from keras-deeplab-v3-plus.

bhack avatar bhack commented on August 27, 2024

Could make sense to load and freeze low-level only weights? https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/model_zoo.md#model-details-2

from keras-deeplab-v3-plus.

wenouyang avatar wenouyang commented on August 27, 2024

@bhack, the link you shared is the tensorflow-based weights, how can I load it in the keras model, please advise. Thanks

https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/model_zoo.md#model-details-2

from keras-deeplab-v3-plus.

bhack avatar bhack commented on August 27, 2024

You need to extend extract_weights.py and load_weights.py in this repository.

from keras-deeplab-v3-plus.

Taylor-Rose avatar Taylor-Rose commented on August 27, 2024

Do I still have to fit after load_weights? or I can directly fit model after model=Deeplabv3()?

from keras-deeplab-v3-plus.

bonlime avatar bonlime commented on August 27, 2024

@Taylor-Rose you don't need to do that anymore. Now weights are loaded if you pass "weights" argument

from keras-deeplab-v3-plus.

Taylor-Rose avatar Taylor-Rose commented on August 27, 2024

@bonlime I did some code like this:
model = Deeplabv3() model.summary() model.fit(train_data,label_data, epochs etc.)
I found that there is no function like 'sigmoid' or 'softmax' on the last layer of the model. In the U-net model I found the function like 'sigmoid' or 'softmax'. What I want to ask is that can I use model.fit() directly after model=Deeplabv3() without any other process. The second I want to ask is that the input data's formation. Does train_data's formation like (512,512,3) with 3 dimension and label_data's formation also like (512,512,3) or should do some preprocess to (class_num, 512,512,3) or other formation?

from keras-deeplab-v3-plus.

bhack avatar bhack commented on August 27, 2024

@bonlime Are the extract_weights/load_weights recovering the BN mean and variance? Check keras-team/keras#3423 (comment).

from keras-deeplab-v3-plus.

bhack avatar bhack commented on August 27, 2024

@bonlime See also this long topic keras-team/keras#9965

from keras-deeplab-v3-plus.

bonlime avatar bonlime commented on August 27, 2024

@bhack sorry for the long answer. Both moving mean and variance are recovered correctly.
btw. Thanks for pointing out the problem with frozen BN. What kind of work around this problem do you personally use?

from keras-deeplab-v3-plus.

JackMing1986 avatar JackMing1986 commented on August 27, 2024

How long can I finish training?

from keras-deeplab-v3-plus.

ChengxiHAN avatar ChengxiHAN commented on August 27, 2024

Have u guys trained new datasets and fine tuned successfully?plz tell me,I wanna try......

from keras-deeplab-v3-plus.

margokhokhlova avatar margokhokhlova commented on August 27, 2024

Hello everyone! Can someone give me an advice, please? I want to try the model on a binary segmentation, shall I add a sigmoid activation to the last model output?

from keras-deeplab-v3-plus.

pluniak avatar pluniak commented on August 27, 2024

@ChengxiHAN @margokhokhlova Did you read issue #56? Yes sigmoid activation on the last layer. I have fine-tuned successfully, but freezing BN-layers while finetuning might cause problems.

from keras-deeplab-v3-plus.

margokhokhlova avatar margokhokhlova commented on August 27, 2024

@pluniak Thank you! Reading it.

from keras-deeplab-v3-plus.

Chenyang-Qu avatar Chenyang-Qu commented on August 27, 2024

@bonlime I did some code like this:
model = Deeplabv3() model.summary() model.fit(train_data,label_data, epochs etc.)
I found that there is no function like 'sigmoid' or 'softmax' on the last layer of the model. In the U-net model I found the function like 'sigmoid' or 'softmax'. What I want to ask is that can I use model.fit() directly after model=Deeplabv3() without any other process. The second I want to ask is that the input data's formation. Does train_data's formation like (512,512,3) with 3 dimension and label_data's formation also like (512,512,3) or should do some preprocess to (class_num, 512,512,3) or other formation?

Hollow.Have you successfully run this model?I got an errror :AttributeError: 'ModelCheckpoint' object has no attribute 'on_train_batch_begin'
I used fit_generator to get train data and val data.

from keras-deeplab-v3-plus.

Zumbalamambo avatar Zumbalamambo commented on August 27, 2024

@Cris-Qu Yes it works perfectly at the moment

from keras-deeplab-v3-plus.

Zumbalamambo avatar Zumbalamambo commented on August 27, 2024

@ChengxiHAN It works fine once we train with the custom dataset. The accuracy was fair enough

from keras-deeplab-v3-plus.

Related Issues (20)

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.