Chaogan-Yan / BrainImageNet

20 stars 9 forks source link

Code for transfer learning #4

Open Kunjal1999 opened 1 year ago

Kunjal1999 commented 1 year ago

Hello, Can you please provide the code for loading the pretrained models and training the loaded model on a custom dataset (i.e. transfer learning)?

Kunjal1999 commented 1 year ago

Can you please give the relevant versions of python, tensorflow and keras for loading the models? I am getting issues like:

ValueError                                Traceback (most recent call last)
[<ipython-input-57-ac2ef0a3374e>](https://localhost:8080/#) in <cell line: 70>()
    158         #   OldModel = load_model('/content/drive/MyDrive/tf/20200427_Phase4_FromScratch_Gender_IncepResN_lr01_AllIn.h5')
    159         #OldModel = keras.models.load_model((path),custom_objects={'Model':hub.Model})
--> 160         ldModel = load_model('/content/drive/MyDrive/tf/20200427_Phase4_FromScratch_Gender_IncepResN_lr01_AllIn.h5')
    161         print(OldModel)
    162         layer_names = [layer.name for layer in OldModel.layers]

2 frames
[/usr/local/lib/python3.10/dist-packages/keras/saving/legacy/serialization.py](https://localhost:8080/#) in class_and_config_for_serialized_keras_object(config, module_objects, custom_objects, printable_module_name)
    366     )
    367     if cls is None:
--> 368         raise ValueError(
    369             f"Unknown {printable_module_name}: '{class_name}'. "
    370             "Please ensure you are using a `keras.utils.custom_object_scope` "

ValueError: Unknown layer: 'Model'. Please ensure you are using a `keras.utils.custom_object_scope` and that this object is included in the scope. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.
Chaogan-Yan commented 1 year ago

Please see https://github.com/Chaogan-Yan/BrainImageNet/blob/master/local/Dockerfile

tensorflow:1.13.1-py3-jupyter