AttributeError: 'Node' object has no attribute 'output_masks' 2023 Mask RCNN

48 Views Asked by At

I have looked at the other solutions presented, especially not mixing keras and tf.keras, and am not having any luck. Maybe because the solutions are mostly from 2019? I also have messed around with the library versions, also to no avail.

My goal is just to get the mask rcnn working on my machine so that I can finally make my own version. I am having a lot of trouble getting it up and running.

I am running this on a venv jupyter notebook.

Import block:

import os
import sys
import random
import math
import numpy as np
import skimage.io
import matplotlib
import matplotlib.pyplot as plt

# Root directory of the project
ROOT_DIR = os.path.abspath("../")

import warnings
warnings.filterwarnings("ignore")

# Import Mask RCNN
sys.path.append(ROOT_DIR)  # To find local version of the library
from mrcnn import utils
import mrcnn.model as modellib
from mrcnn import visualize
# Import COCO config
import samples.coco.coco as coco

%matplotlib inline

Problematic block:

# Create model object in inference mode.
model = modellib.MaskRCNN(mode="inference", model_dir='mask_rcnn_coco.hy', config=config)

Full error message:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[55], line 2
      1 # Create model object in inference mode.
----> 2 model = modellib.MaskRCNN(mode="inference", model_dir='mask_rcnn_coco.hy', config=config)
      4 # Load weights trained on MS-COCO
      5 model.load_weights('mask_rcnn_coco.h5', by_name=True)

File ~\Desktop\Spore\spore\Mask_RCNN\mrcnn\model.py:1837, in MaskRCNN.__init__(self, mode, config, model_dir)
   1835 self.model_dir = model_dir
   1836 self.set_log_dir()
-> 1837 self.keras_model = self.build(mode=mode, config=config)

File ~\Desktop\Spore\spore\Mask_RCNN\mrcnn\model.py:1961, in MaskRCNN.build(self, mode, config)
   1956 # Generate proposals
   1957 # Proposals are [batch, N, (y1, x1, y2, x2)] in normalized coordinates
   1958 # and zero padded.
   1959 proposal_count = config.POST_NMS_ROIS_TRAINING if mode == "training"\
   1960     else config.POST_NMS_ROIS_INFERENCE
-> 1961 rpn_rois = ProposalLayer(
   1962     proposal_count=proposal_count,
   1963     nms_threshold=config.RPN_NMS_THRESHOLD,
   1964     name="ROI",
   1965     config=config)([rpn_class, rpn_bbox, anchors])
   1967 if mode == "training":
   1968     # Class ID mask to mark class IDs supported by the dataset the image
   1969     # came from.
   1970     active_class_ids = KL.Lambda(
   1971         lambda x: parse_image_meta_graph(x)["active_class_ids"]
   1972         )(input_image_meta)

File ~\Desktop\Spore\spore\lib\site-packages\keras\engine\topology.py:589, in __call__(self, inputs, **kwargs)

File ~\Desktop\Spore\spore\lib\site-packages\keras\engine\topology.py:2799, in _collect_previous_mask(input_tensors)

AttributeError: 'Node' object has no attribute 'output_masks'

I don't know what to even try at this point; any advice?

0

There are 0 best solutions below