Keras-ICNet icon indicating copy to clipboard operation
Keras-ICNet copied to clipboard

NameError: name 'tf' is not defined when I loda the checkpoint file at training.

Open zeyuDai2018 opened this issue 6 years ago • 1 comments

After I trained on my own dataset with width 800 height 480 without checkpoint successfully, I fill in the checkpoint parameter and tried the test image and this error showed up. The exact error is like this:

Traceback (most recent call last): File "train", line 55, in net = load_model(opt.checkpoint) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\saving.py", line 225, in deserialize_model model = model_from_config(model_config, custom_objects=custom_objects) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\saving.py", line 458, in model_from_config return deserialize(config, custom_objects=custom_objects) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\layers_init.py", line 55, in deserialize printable_module_name='layer') File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\utils\generic_utils.py", line 145, in deserialize_keras_object list(custom_objects.items()))) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\network.py", line 1032, in from_config process_node(layer, node_data) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\network.py", line 991, in process_node layer(unpack_singleton(input_tensors), **kwargs) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\engine\base_layer.py", line 457, in call output = self.call(inputs, **kwargs) File "C:\DDDDZZZZYYYY\envs\kerass\lib\site-packages\keras\layers\core.py", line 687, in call return self.function(inputs, **arguments) File "C:\Users\In-Car DVR\Desktop\DZY-work\Keras-ICNet-master\model.py", line 195, in y = Lambda(lambda x: tf.image.resize_bilinear(x, size=(int(x.shape[1])//2, int(x.shape[2])//2)), name='data_sub2')(x) NameError: name 'tf' is not defined

The training process showed the same error when I put in the checkpoint parameters. Is the file in the output folder the checkpoint file? Or the checkpoint file is in some other locations?

Thanks in advance!

zeyuDai2018 avatar Jun 25 '19 01:06 zeyuDai2018

I think is the same problem that occurs in the 'test' file code. Here is the solution https://github.com/aitorzip/Keras-ICNet/issues/2#issuecomment-555954104

At summary, the solution is adding the 'tf' import by 'custom_objetcs' atribute: net = load_model(opt.checkpoint, custom_objects={'tf': tf})

YeahYo17 avatar Nov 20 '19 11:11 YeahYo17