keras-deeplab-v3-plus
keras-deeplab-v3-plus copied to clipboard
AttributeError: 'int' object has no attribute 'value'
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)
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'
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 :) ).