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

ValueError: Output tensors to a Model must be the output of a TensorFlow Layer (thus holding past layer metadata). Found: Tensor("mrcnn_class_logits_5/transpose_1:0", shape=(4, ?, 3), dtype=float32) #18

Closed
ruchika61 opened this issue Oct 19, 2020 · 7 comments

Comments

@ruchika61
Copy link

No description provided.

@ruchika61
Copy link
Author

hi
i am getting this error at
train_maskrcnn.load_pretrained_model("mask_rcnn_coco.h5")
kindly tell the soluion.
Also for custom dataset i am getting error
RuntimeError: Exception thrown in SimpleITK ReadImage: D:\a\1\sitk\Code\IO\src\sitkImageReaderBase.cxx:107:
sitk::ERROR: Unable to determine ImageIO reader for "C:\Users\dell\Desktop\Custom Semantic Segmentation\chest\train\17.png"
at
vis_img.visualize_sample().
waiting for your reply.

@ruchika61
Copy link
Author

hi
i am getting above error at
train_maskrcnn.load_pretrained_model("mask_rcnn_coco.h5")
kindly tell the soluion.
Also for custom dataset i am getting error
RuntimeError: Exception thrown in SimpleITK ReadImage: D:\a\1\sitk\Code\IO\src\sitkImageReaderBase.cxx:107:
sitk::ERROR: Unable to determine ImageIO reader for "C:\Users\dell\Desktop\Custom Semantic Segmentation\chest\train\17.png"
at
vis_img.visualize_sample().
waiting for your reply.

at
train_maskrcnn.load_pretrained_model("mask_rcnn_coco.h5")
kindly tell the soluion.
Also for custom dataset i am getting error
RuntimeError: Exception thrown in SimpleITK ReadImage: D:\a\1\sitk\Code\IO\src\sitkImageReaderBase.cxx:107:
sitk::ERROR: Unable to determine ImageIO reader for "C:\Users\dell\Desktop\Custom Semantic Segmentation\chest\train\17.png"
at
vis_img.visualize_sample().
waiting for your reply.

@ayoolaolafenwa
Copy link
Owner

Provide your full code. Do you prepare the dataset with labelme? Does the number of classes you pass into the code match the classes available in the dataset?

@ruchika61
Copy link
Author

Hi
Thanks for your reply
Yes, I have prepared dataset to labelme. Yes, I have entered same number of classes into code.
code is same as yours
I tried first to work with Nature dataset as you said. But in that i am getting this error

runfile('C:/Users/dell/Desktop/Custom Semantic Segmentation/demo.py', wdir='C:/Users/dell/Desktop/Custom Semantic Segmentation')
Reloaded modules: SimpleITK, SimpleITK.SimpleITK, SimpleITK._SimpleITK
Using resnet101 as network backbone For Mask R-CNN model
WARNING:tensorflow:From C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/dell/Desktop/Custom Semantic Segmentation/demo.py', wdir='C:/Users/dell/Desktop/Custom Semantic Segmentation')

File "C:\Users\dell\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile
execfile(filename, namespace)

File "C:\Users\dell\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/dell/Desktop/Custom Semantic Segmentation/demo.py", line 15, in
train_maskrcnn.load_pretrained_model("mask_rcnn_coco.h5")

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\custom_train.py", line 50, in load_pretrained_model
self.model = modellib.MaskRCNN(mode="training", model_dir = self.model_dir, config=self.config)

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\mask_rcnn.py", line 1822, in init
self.keras_model = self.build(mode=mode, config=config)

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\mask_rcnn.py", line 2017, in build
model = KM.Model(inputs, outputs, name='mask_rcnn')

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py", line 121, in init
super(Model, self).init(*args, **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\network.py", line 81, in init
self._init_graph_network(*args, **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\training\checkpointable\base.py", line 442, in _method_wrapper
method(self, *args, **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\network.py", line 177, in _init_graph_network
self._validate_graph_inputs_and_outputs()

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\network.py", line 1673, in _validate_graph_inputs_and_outputs
'(thus holding past layer metadata). Found: ' + str(x))

ValueError: Output tensors to a Model must be the output of a TensorFlow Layer (thus holding past layer metadata). Found: Tensor("mrcnn_class_logits/transpose_1:0", shape=(4, ?, 3), dtype=float32)

@ruchika61
Copy link
Author

when i tried on my custom dataset and chenged load_dataset function Nature with custom dataset, i am getting this error

runfile('C:/Users/dell/Desktop/Custom Semantic Segmentation/chest.py', wdir='C:/Users/dell/Desktop/Custom Semantic Segmentation')
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/dell/Desktop/Custom Semantic Segmentation/chest.py', wdir='C:/Users/dell/Desktop/Custom Semantic Segmentation')

File "C:\Users\dell\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile
execfile(filename, namespace)

File "C:\Users\dell\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/dell/Desktop/Custom Semantic Segmentation/chest.py", line 12, in
vis_img.visualize_sample()

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\custom_train.py", line 88, in visualize_sample
image = self.dataset_train.load_image(image_id)

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\utils.py", line 362, in load_image
image = skimage.io.imread(self.image_info[image_id]['path'])

File "C:\Users\dell\Anaconda3\lib\site-packages\skimage\io_io.py", line 61, in imread
img = call_plugin('imread', fname, plugin=plugin, **plugin_args)

File "C:\Users\dell\Anaconda3\lib\site-packages\skimage\io\manage_plugins.py", line 210, in call_plugin
return func(*args, **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\core\functions.py", line 221, in imread
reader = read(uri, format, "i", **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\core\functions.py", line 143, in get_reader
return format.get_reader(request)

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\core\format.py", line 174, in get_reader
return self.Reader(self, request)

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\core\format.py", line 224, in init
self._open(**self.request.kwargs.copy())

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\plugins\simpleitk.py", line 84, in _open
self._img = _itk.ReadImage(self.request.get_local_filename())

File "C:\Users\dell\AppData\Roaming\Python\Python37\site-packages\SimpleITK\SimpleITK.py", line 8876, in ReadImage
return _SimpleITK.ReadImage(*args)

RuntimeError: Exception thrown in SimpleITK ReadImage: D:\a\1\sitk\Code\IO\src\sitkImageReaderBase.cxx:107:
sitk::ERROR: Unable to determine ImageIO reader for "C:\Users\dell\Desktop\Custom Semantic Segmentation\chest\train\97.png"

Codes are common and same as:
import pixellib
from pixellib.custom_train import instance_custom_training

vis_img = instance_custom_training()
vis_img.load_dataset("chest")
vis_img.visualize_sample()

train_maskrcnn.modelConfig(network_backbone = "resnet101", num_classes= 7, batch_size = 4)
train_maskrcnn.load_pretrained_model("mask_rcnn_coco.h5")
train_maskrcnn.load_dataset("chest")
train_maskrcnn.train_model(num_epochs = 300, augmentation=True, path_trained_models = "mask_rcnn_models")

@ayoolaolafenwa
Copy link
Owner

Hi
Thanks for your reply
Yes, I have prepared dataset to labelme. Yes, I have entered same number of classes into code.
code is same as yours
I tried first to work with Nature dataset as you said. But in that i am getting this error

runfile('C:/Users/dell/Desktop/Custom Semantic Segmentation/demo.py', wdir='C:/Users/dell/Desktop/Custom Semantic Segmentation')
Reloaded modules: SimpleITK, SimpleITK.SimpleITK, SimpleITK._SimpleITK
Using resnet101 as network backbone For Mask R-CNN model
WARNING:tensorflow:From C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/dell/Desktop/Custom Semantic Segmentation/demo.py', wdir='C:/Users/dell/Desktop/Custom Semantic Segmentation')

File "C:\Users\dell\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile
execfile(filename, namespace)

File "C:\Users\dell\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/dell/Desktop/Custom Semantic Segmentation/demo.py", line 15, in
train_maskrcnn.load_pretrained_model("mask_rcnn_coco.h5")

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\custom_train.py", line 50, in load_pretrained_model
self.model = modellib.MaskRCNN(mode="training", model_dir = self.model_dir, config=self.config)

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\mask_rcnn.py", line 1822, in init
self.keras_model = self.build(mode=mode, config=config)

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\mask_rcnn.py", line 2017, in build
model = KM.Model(inputs, outputs, name='mask_rcnn')

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py", line 121, in init
super(Model, self).init(*args, **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\network.py", line 81, in init
self._init_graph_network(*args, **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\training\checkpointable\base.py", line 442, in _method_wrapper
method(self, *args, **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\network.py", line 177, in _init_graph_network
self._validate_graph_inputs_and_outputs()

File "C:\Users\dell\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\network.py", line 1673, in _validate_graph_inputs_and_outputs
'(thus holding past layer metadata). Found: ' + str(x))

ValueError: Output tensors to a Model must be the output of a TensorFlow Layer (thus holding past layer metadata). Found: Tensor("mrcnn_class_logits/transpose_1:0", shape=(4, ?, 3), dtype=float32)

This is not an issue with PixelLib. Ensure that you have installed tensorflow properly. It appears like you are using anaconda3, ensure that you installed a compatible tensorflow version.

@ayoolaolafenwa
Copy link
Owner

ayoolaolafenwa commented Oct 20, 2020

when i tried on my custom dataset and chenged load_dataset function Nature with custom dataset, i am getting this error

runfile('C:/Users/dell/Desktop/Custom Semantic Segmentation/chest.py', wdir='C:/Users/dell/Desktop/Custom Semantic Segmentation')
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/dell/Desktop/Custom Semantic Segmentation/chest.py', wdir='C:/Users/dell/Desktop/Custom Semantic Segmentation')

File "C:\Users\dell\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile
execfile(filename, namespace)

File "C:\Users\dell\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/dell/Desktop/Custom Semantic Segmentation/chest.py", line 12, in
vis_img.visualize_sample()

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\custom_train.py", line 88, in visualize_sample
image = self.dataset_train.load_image(image_id)

File "C:\Users\dell\Anaconda3\lib\site-packages\pixellib\utils.py", line 362, in load_image
image = skimage.io.imread(self.image_info[image_id]['path'])

File "C:\Users\dell\Anaconda3\lib\site-packages\skimage\io_io.py", line 61, in imread
img = call_plugin('imread', fname, plugin=plugin, **plugin_args)

File "C:\Users\dell\Anaconda3\lib\site-packages\skimage\io\manage_plugins.py", line 210, in call_plugin
return func(*args, **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\core\functions.py", line 221, in imread
reader = read(uri, format, "i", **kwargs)

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\core\functions.py", line 143, in get_reader
return format.get_reader(request)

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\core\format.py", line 174, in get_reader
return self.Reader(self, request)

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\core\format.py", line 224, in init
self._open(**self.request.kwargs.copy())

File "C:\Users\dell\Anaconda3\lib\site-packages\imageio\plugins\simpleitk.py", line 84, in _open
self._img = _itk.ReadImage(self.request.get_local_filename())

File "C:\Users\dell\AppData\Roaming\Python\Python37\site-packages\SimpleITK\SimpleITK.py", line 8876, in ReadImage
return _SimpleITK.ReadImage(*args)

RuntimeError: Exception thrown in SimpleITK ReadImage: D:\a\1\sitk\Code\IO\src\sitkImageReaderBase.cxx:107:
sitk::ERROR: Unable to determine ImageIO reader for "C:\Users\dell\Desktop\Custom Semantic Segmentation\chest\train\97.png"

Codes are common and same as:
import pixellib
from pixellib.custom_train import instance_custom_training

vis_img = instance_custom_training()
vis_img.load_dataset("chest")
vis_img.visualize_sample()

train_maskrcnn.modelConfig(network_backbone = "resnet101", num_classes= 7, batch_size = 4)
train_maskrcnn.load_pretrained_model("mask_rcnn_coco.h5")
train_maskrcnn.load_dataset("chest")
train_maskrcnn.train_model(num_epochs = 300, augmentation=True, path_trained_models = "mask_rcnn_models")

This is also not an issue with PixelLib. Check these similar issues on Runtime Error on SimpleITK ReadImage, they may be helpful.

SimpleITK/SimpleITK#434

junqiangchen/KiTS19-Challege#4

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