SUYEgit / Surgery-Robot-Detection-Segmentation

Object detection and segmentation for a surgery robot using Mask-RCNN on Python 3, Keras, and TensorFlow..
Other
181 stars 84 forks source link

AttributeError: 'list' object has no attribute 'values' #9

Closed eyildiz-ugoe closed 6 years ago

eyildiz-ugoe commented 6 years ago

As described in the balloon example, I've used VIA tool to annotate my images. I've used circles, polygons, etc. and gave each class its respective name.

1 2

Now that I want to load the dataset, using your code, and I get the following error:

Traceback (most recent call last):
  File "components.py", line 522, in <module>
    train(model)
  File "components.py", line 231, in train
    dataset_train.load_components(args.dataset, "train")
  File "components.py", line 124, in load_components
    polygons = [r['shape_attributes'] for r in a['regions'].values()]
AttributeError: 'list' object has no attribute 'values'

What could be the problem? Has anyone tried loading the annotated data which contains circles? (not only polygons)

P.S: Here is the code snippet (taken from surgery.py) to load the data.

# Add images
        for a in annotations:
            # Get the x, y coordinaets of points of the polygons that make up
            # the outline of each object instance. There are stored in the
            # shape_attributes (see json format above)
            polygons = [r['shape_attributes'] for r in a['regions'].values()]
            names = [r['region_attributes'] for r in a['regions'].values()]
            # load_mask() needs the image size to convert polygons to masks.
            # Unfortunately, VIA doesn't include it in JSON, so we must read
            # the image. This is only managable since the dataset is tiny.
            image_path = os.path.join(dataset_dir, a['filename'])
            image = skimage.io.imread(image_path)
            height, width = image.shape[:2]

            self.add_image(
                "components",
                image_id=a['filename'],  # use file name as a unique image id
                path=image_path,
                width=width, height=height,
                polygons=polygons,
                names=names)
eyildiz-ugoe commented 6 years ago

It's because the loader only accepts polygons, which is quite bad, tbh.

Gauravi24 commented 4 years ago

It's because the loader only accepts polygons, which is quite bad, tbh.

i have polylines would it still not work. What is the other way to load any idea

eyildiz-ugoe commented 4 years ago

No, it has to be polygons. And it has been long time so I kinda lost my touch to that project, sorry, can't help further I am afraid.

Gauravi24 commented 4 years ago

Thank you.

On Tue, 12 May 2020, 5:15 pm Erenus Yildiz, notifications@github.com wrote:

No, it has to be polygons. And it has been long time so I kinda lost my touch to that project, sorry, can't help further I am afraid.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SUYEgit/Surgery-Robot-Detection-Segmentation/issues/9#issuecomment-627292646, or unsubscribe https://github.com/notifications/unsubscribe-auth/APIYAY4LPHZGCQKO2EDAXKTRREZHBANCNFSM4FU572OQ .