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

AttributeError: 'int' object has no attribute 'value' #144

Open
alikarimi120 opened this issue May 19, 2020 · 1 comment
Open

AttributeError: 'int' object has no attribute 'value' #144

alikarimi120 opened this issue May 19, 2020 · 1 comment

Comments

@alikarimi120
Copy link

alikarimi120 commented May 19, 2020

I copy and run this code(and copy images and model.py) :

from matplotlib import pyplot as plt
import cv2 # used for resize. if you dont have it, use anything else
import numpy as np
from model import Deeplabv3
img = plt.imread("imgs/image1.jpg")
print(img.shape)
w, h, _ = img.shape
ratio = 512. / np.max([w,h])
resized = cv2.resize(img,(int(ratioh),int(ratiow)))
resized = resized / 127.5 - 1.
new_deeplab_model = Deeplabv3(input_shape=(512,512,3), OS=16)

pad_x = int(512 - resized.shape[0])
resized2 = np.pad(resized,((0,pad_x),(0,0),(0,0)), mode='constant')
res = new_deeplab_model.predict(np.expand_dims(resized2,0))
res_old = old_deeplab_model.predict(np.expand_dims(resized2,0))
labels = np.argmax(res.squeeze(),-1)
labels_old = np.argmax(res_old.squeeze(),-1)
plt.imshow(labels[:-pad_x])
plt.show()
plt.imshow(labels_old[:-pad_x])
plt.show()
`

but I get this error =>

ERROR:root:An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line string', (1, 2))


TypeError Traceback (most recent call last)
in ()
26 # make prediction
27 deeplab_model = Deeplabv3()
---> 28 res = deeplab_model.predict(np.expand_dims(resized_image, 0))
29 labels = np.argmax(res.squeeze(), -1)
30

10 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs)
966 func_graph: A FuncGraph object to destroy. func_graph is unusable
967 after this function.
--> 968 """
969 # TODO(b/115366440): Delete this method when a custom OrderedDict is added.
970 # Clearing captures using clear() leaves some cycles around.

TypeError: in user code:

TypeError: tf__predict_function() missing 8 required positional arguments: 'x', 'batch_size', 'verbose', 'steps', 'callbacks', 'max_queue_size', 'workers', and 'use_multiprocessing'
@tempdeltavalue
Copy link

In my case problem was in inputs.shape[-1].value inside _inverted_res_block , so I just removed ".value" and everything worked (maybe for now :) ).

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