A COCO image and masks generator tutorial for semantic segmentation purposes.
Refer to the demo jupyter notebook for the self-explanatory code.
A COCO image and masks generator tutorial for semantic segmentation purposes.
A COCO image and masks generator tutorial for semantic segmentation purposes.
Refer to the demo jupyter notebook for the self-explanatory code.
Hi, Thank you for creating this tutorial. I'm wondering if there is a way to modify the script so that each pixel value for an object is the same. For example, if I have an object that is category id 4, the current script produces a mask that has values of 0, 1, 2, 3, 4. But I want all pixels to be either 0 (background) or 4 (object).
I tried modifying the script to do this, but I'm pretty confused when it comes to using the coco library.
Thank you
@virafpatrawala thanks for nice, Can you guide me how I can save the image to desk to generate png mask images. Thanks
I get the following error whenever I try to run coco.annToMask(anns[i]):
ValueError: Buffer has wrong number of dimensions (expected 1, got 2).
All I was doing was following the code exactly. It was working one day, then all of a sudden it wasn't the next. Anyone know how to resolve this?
Thanks,
Sam
@virafpatrawala Hi, first of all thanks for your article. I think your code is all I need to finish my project. I need to transform a json file with a lot of annotations for different images into segmentation masks png's, and also I thin I'm going to use your data augmentation part too.
I'm not using coco images but my own dataset with coco annotations and I got this error
My dataset have images of 550x550 pixels but I got the same error when I inserted that number in the input_image_size
Thank you for your time
Miguel
2 root error(s) found.
(0) UNKNOWN: Exception: input type is not supported.
Traceback (most recent call last):
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/tensorflow/python/ops/script_ops.py", line 270, in call
ret = func(*args)
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py", line 642, in wrapper
return func(*args, **kwargs)
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1030, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/keras/engine/data_adapter.py", line 831, in wrapped_generator
for data in generator_fn():
File "/tmp/ipykernel_235356/1226860277.py", line 14, in augmentationsGenerator
for img, mask in gen:
File "/tmp/ipykernel_235356/728327123.py", line 25, in dataGeneratorCoco
train_mask = getNormalMask(imageObj, classes, coco, catIds, input_image_size)
File "/tmp/ipykernel_235356/2567587607.py", line 29, in getNormalMask
new_mask = cv2.resize(coco.annToMask(anns[a])*pixel_value, input_image_size)
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/pycocotools/coco.py", line 442, in annToMask
rle = self.annToRLE(ann)
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/pycocotools/coco.py", line 427, in annToRLE
rles = maskUtils.frPyObjects(segm, h, w)
File "pycocotools/_mask.pyx", line 308, in pycocotools._mask.frPyObjects
Exception: input type is not supported.
[[{{node PyFunc}}]]
[[IteratorGetNext]]
[[IteratorGetNext/_4]]
(1) UNKNOWN: Exception: input type is not supported.
Traceback (most recent call last):
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/tensorflow/python/ops/script_ops.py", line 270, in call
ret = func(*args)
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py", line 642, in wrapper
return func(*args, **kwargs)
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1030, in generator_py_func
values = next(generator_state.get_iterator(iterator_id))
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/keras/engine/data_adapter.py", line 831, in wrapped_generator
for data in generator_fn():
File "/tmp/ipykernel_235356/1226860277.py", line 14, in augmentationsGenerator
for img, mask in gen:
File "/tmp/ipykernel_235356/728327123.py", line 25, in dataGeneratorCoco
train_mask = getNormalMask(imageObj, classes, coco, catIds, input_image_size)
File "/tmp/ipykernel_235356/2567587607.py", line 29, in getNormalMask
new_mask = cv2.resize(coco.annToMask(anns[a])*pixel_value, input_image_size)
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/pycocotools/coco.py", line 442, in annToMask
rle = self.annToRLE(ann)
File "/home/navneeth/anaconda3/lib/python3.9/site-packages/pycocotools/coco.py", line 427, in annToRLE
rles = maskUtils.frPyObjects(segm, h, w)
File "pycocotools/_mask.pyx", line 308, in pycocotools._mask.frPyObjects
Exception: input type is not supported.
[[{{node PyFunc}}]]
[[IteratorGetNext]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_3047]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.