Open mia2mia opened 6 years ago
Hi, there. Maybe it's because of you annotated your training images with rectangles but not polygons? Check the region_data.json which the annotation tools produced, you will find out there is no "all_points_y" for rectangles. The sample in this repo is using polygons for annotations, "skimage.draw.polygon" said.
I am having this problem too, I have rectangles and polygons on my annotations. How can I solve this problem?
I suggest you just simply replace all of the rectangles with polygons using VIA tools for example.
Or you can try to modify the via_region_data.json file, replace the "x" and "y" with "all_points_x" and "all_points_y"(and you need to calculate the x[1] and y[1] with "width" and "height") in the file, remove the "width" and "height"(add them into x[1] and y[1]), then change the "name" from rect to polygon.
Yes @chohaku84 replacing all rectangles with polygons removed the error.
@chohaku84 why all_points_y stand the first rather than all_points_x? And also: height, width = image.shape[:2] Width should be first, isnt it?
@mia2mia I'm glad it helped. @Oktai15 In the region_data.json VIA tools produced, there are points_x stands before points_y, as same as width stands before height for rectangle objects. While skimage.draw API defines the first param to be "row coordinates" ndarray and the second param to be "column coordinates" ndarray. So in this case, 'all_points_y' for row coordinates, 'all_points_x' for column coordinates are passed into "skimage.draw.polygon".
I am working on Mask R-CNN, I am training images. I have 1 + 1 class.In my JSON I have 2 shape: 'rect ' and 'polygon'. My not working when I added 'rect' also on same data set. Let how to handle the different shapes. My program only works with polygon shapes
@chohaku84 I have circles and rectangles in my json instead of polygons. From the previous comments, converting rect to polygon is possible. But what do you do when you have circle. In circle it has cx, cy , r.
I am also have the same problem @chohaku84 did you find any solution for that.
Hey, I am getting the same error even after changing all annotations to polygon. My code trains fine for first 100 iterations in first epoch and then it shows the following error: Traceback (most recent call last): File "/home/dipesh/anaconda3/envs/maskrcnn/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/home/dipesh/anaconda3/envs/maskrcnn/lib/python3.6/site-packages/keras/utils/data_utils.py", line 626, in next_sample return six.next(_SHARED_SEQUENCES[uid]) File "/home/dipesh/anaconda3/envs/maskrcnn/lib/python3.6/site-packages/mask_rcnn-2.1-py3.6.egg/mrcnn/model.py", line 1710, in data_generator use_mini_mask=config.USE_MINI_MASK) File "/home/dipesh/anaconda3/envs/maskrcnn/lib/python3.6/site-packages/mask_rcnn-2.1-py3.6.egg/mrcnn/model.py", line 1213, in load_image_gt mask, class_ids = dataset.load_mask(image_id) File "cancer.py", line 173, in load_mask rr, cc = skimage.draw.polygon(p['all_points_y'], p['all_points_x']) KeyError: 'all_points_y' """
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "cancer.py", line 533, in
Using Linux 18.04 Python 3.7.0
I am trying to train Mask RCNN on my own data but I get the errors below when training or loading the mini mask or using the modellib.data_generator.
Anyone else had this problem?
ERROR:root:Error processing image {'id': 'location-494-270.jpg', 'source': 'flowers', 'path': '/home/ubuntu/ssl/notebooks/Mask_RCNN/Mask_RCNN/datasets/flowers/train/file2.jpg', 'width': 640, 'height': 400, 'polygons': [{'name': 'rect', 'x': 301, 'y': 178, 'width': 40, 'height': 93}]} Traceback (most recent call last): File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/mask_rcnn-2.1-py3.6.egg/mrcnn/model.py", line 1692, in data_generator use_mini_mask=config.USE_MINI_MASK) File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/mask_rcnn-2.1-py3.6.egg/mrcnn/model.py", line 1207, in load_image_gt mask, class_ids = dataset.load_mask(image_id) File "flowers.py", line 158, in load_mask rr, cc = skimage.draw.polygon(p['all_points_y'], p['all_points_x']) KeyError: 'all_points_y'Epoch 1/30