cocodataset / cocoapi

COCO API - Dataset @ http://cocodataset.org/
Other
6.06k stars 3.75k forks source link

Hi I am confused in using the coco api , especially about segmentation task of mask api. Can anyone give some example about segmentation task relate api please? #83

Open lianshushu opened 6 years ago

nightrome commented 6 years ago

I assume you are talking about object/thing segmentation. In that case take a look at https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoDemo.ipynb . For stuff segmentation go to https://github.com/nightrome/cocoapi

lianshushu commented 6 years ago

I had read the demon program but did not get help for my work. I need to get the instance segmentaion label for every image. Do you have any example or document about the kind of operation please. Thank you so much!

lianshushu commented 6 years ago

when given an image name , I want to get all instances or object label in this image from 0-80 pixel by pixel. The demon code seems to be given an instance class id and get you the image id(name) which made confused.

nightrome commented 6 years ago

You can always ignore some of the fields: annIds = coco_kps.getAnnIds(imgIds=img['id'], catIds=catIds, iscrowd=None) Just don't set catIds. Then run anns = coco_kps.loadAnns(annIds) And then convert the annotations to a pixel level mask, similar to https://github.com/nightrome/cocoapi/blob/master/PythonAPI/pycocotools/cocostuffhelper.py#L98

Shanzaay commented 5 years ago

After a lot of effort and search, I was finally able to install coco API. I am trying to run a video captioning code. A neural network for video captioning. These are the libraries which are not executing because anaconda coco API doesn't work anymore. But I installed it anyway. from pycocoevalcap.tokenizer.ptbtokenizer import PTBTokenizer from pycocoevalcap.bleu.bleu import Bleu from pycocoevalcap.meteor.meteor import Meteor from pycocoevalcap.rouge.rouge import Rouge from pycocoevalcap.cider.cider import Cider

The only line that is executing is this one. from pycocotools.coco import COCO

How do I run the rest of the above library lines?

Thanks in advance.

nightrome commented 5 years ago

@Shanzaay I don't think you properly setup the API. The file is at https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocotools/coco.py . Somehow that folder does not seem to be on your PYTHONPATH.

Shanzaay commented 5 years ago

@nightrome it's my first time with this kinda thing. Call me a newbie. Now I am more confused than before. Can you guide me in this? How do I make those libraries execute and how to properly install coco API. And yeah you are right now I am having an error even on this line now: from pycocotools.coco import COCO

A step by step guidance will be great.

Thanks a lot.

nightrome commented 5 years ago

@Shanzaay The instructions are at: https://github.com/cocodataset/cocoapi You can verify your PYTHONPATH by doing echo $PYTHONPATH. If there is no entry there for COCO, then check the various other issues in this forum and see if anyone has similar problems.

Shanzaay commented 5 years ago

Ok, I'll try it @nightrome. And thanks a bunch.

Shanzaay commented 5 years ago

@nightrome so here are the steps i performed: I clone the repo i commented this line in setup.py:

extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'],

other wise it give error

once it installed i get something like this: Using c:\users\myusername\anaconda3\lib\site-packages Finished processing dependencies for pycocotools==2.0

But i am still having the error. What is it that i am doing wrong?

nightrome commented 5 years ago

@Shanzaay Sorry, I haven't tried it on Windows. Please take a look at the various other Windows issues, e.g. https://github.com/cocodataset/cocoapi/issues/9

Shanzaay commented 5 years ago

Ok thanks. @nightrome does cocoAPI is not supported by Python 3?

nightrome commented 5 years ago

Python 3 should not be a problem. But they officially state on the link above that Windows is not supported.

virafpatrawala commented 4 years ago

Hey, I have recently written an entire post on exploring and manipulating the COCO dataset for Image Segmentation. Do have a look.

xml94 commented 4 years ago

Hey, I have recently written an entire post on exploring and manipulating the COCO dataset for Image Segmentation. Do have a look.

I read your post, and my got my answer about how to get mask from the dataset. Thanks a lot.