Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zeyuDai2018 opened this issue Jun 25, 2019 · 1 comment

Comments

@zeyuDai2018
Copy link

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!

@YeahYo17
Copy link

YeahYo17 commented Nov 20, 2019

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})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants