aitorzip / Keras-ICNet

Keras implementation of Real-Time Semantic Segmentation on High-Resolution Images

Home Page:https://arxiv.org/abs/1704.08545

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

zeyuDai2018 opened this issue · 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!

I think is the same problem that occurs in the 'test' file code. Here is the solution #2 (comment)

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