aurora95 / Keras-FCN

Keras-tensorflow implementation of Fully Convolutional Networks for Semantic Segmentation(Unfinished)
MIT License
650 stars 268 forks source link

NameError: name 'transform_matrix_offset_center' is not defined #85

Open songyu3044 opened 5 years ago

songyu3044 commented 5 years ago

i meet this question NameError: name 'transform_matrix_offset_center' is not defined please help me

YANRUI121 commented 5 years ago

I had the same problem, and when I added the following function definition which is from keras.preprocessing.image.ImageDataGenerator, the error was fixed.

def transform_matrix_offset_center(matrix, x, y): o_x = float(x) / 2 + 0.5 o_y = float(y) / 2 + 0.5 offset_matrix = np.array([[1, 0, o_x], [0, 1, o_y], [0, 0, 1]]) reset_matrix = np.array([[1, 0, -o_x], [0, 1, -o_y], [0, 0, 1]]) transform_matrix = np.dot(np.dot(offset_matrix, matrix), reset_matrix) return transform_matrix

Traceback (most recent call last): File "train.py", line 237, in label_suffix=label_suffix, ignore_label=ignore_label, label_cval=label_cval) File "train.py", line 169, in train class_weight=class_weight File "/home/yanrui/anaconda3/lib/python3.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, kwargs) File "/home/yanrui/anaconda3/lib/python3.7/site-packages/keras/engine/training.py", line 1418, in fit_generator initial_epoch=initial_epoch) File "/home/yanrui/anaconda3/lib/python3.7/site-packages/keras/engine/training_generator.py", line 181, in fit_generator generator_output = next(output_generator) File "/home/yanrui/anaconda3/lib/python3.7/site-packages/keras/utils/data_utils.py", line 601, in get six.reraise(sys.exc_info()) File "/home/yanrui/anaconda3/lib/python3.7/site-packages/six.py", line 693, in reraise raise value File "/home/yanrui/anaconda3/lib/python3.7/site-packages/keras/utils/data_utils.py", line 595, in get inputs = self.queue.get(block=True).get() File "/home/yanrui/anaconda3/lib/python3.7/multiprocessing/pool.py", line 657, in get raise self._value File "/home/yanrui/anaconda3/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(args, kwds)) File "/home/yanrui/anaconda3/lib/python3.7/site-packages/keras/utils/data_utils.py", line 401, in get_index return _SHARED_SEQUENCES[uid][i] File "/home/yanrui/anaconda3/lib/python3.7/site-packages/keras_preprocessing/image/iterator.py", line 65, in getitem return self._get_batches_of_transformed_samples(index_array) File "/home/yanrui/src/Keras-FCN/utils/SegDataGenerator.py", line 260, in _get_batches_of_transformed_samples x, y = self.seg_data_generator.random_transform(x, y) File "/home/yanrui/src/Keras-FCN/utils/SegDataGenerator.py", line 461, in random_transform transform_matrix = transform_matrix_offset_center( NameError: name 'transform_matrix_offset_center' is not defined

songyu3044 commented 5 years ago

I've solved this problem, but I'm sorry. I forgot how to solve it at that time. As I recall, you maybe install keras 2.1.6 or check keras-contrib is right. if you do this ,you cant solve it .you can add my wechat: zm2634039766