COCO數據集使用super categories時出現IndexError: list index out of range


在文件xxx/site-packages/pycocotools-2.0-py3.7-linux-x86_64.egg/pycocotools/coco.py中找到約157行左右的函數

def getCatIds(self, catNms=[], supNms=[], catIds=[]):

改為:

 

    def getCatIds(self, catNms=[], supNms=[], catIds=[]):
        """
        filtering parameters. default skips that filter.
        :param catNms (str array)  : get cats for given cat names
        :param supNms (str array)  : get cats for given supercategory names
        :param catIds (int array)  : get cats for given cat ids
        :return: ids (int array)   : integer array of cat ids
        """
        #catNms = catNms if _isArrayLike(catNms) else [catNms]
        #supNms = supNms if _isArrayLike(supNms) else [supNms]
        #catIds = catIds if _isArrayLike(catIds) else [catIds]

        #if len(catNms) == len(supNms) == len(catIds) == 0:
        #    cats = self.dataset['categories']
        #else:
        #    cats = self.dataset['categories']
        #    cats = cats if len(catNms) == 0 else [cat for cat in cats if cat['name']          in catNms]
        #    cats = cats if len(supNms) == 0 else [cat for cat in cats if cat['supercategory'] in supNms]
        #    cats = cats if len(catIds) == 0 else [cat for cat in cats if cat['id']            in catIds]
        #ids = [cat['id'] for cat in cats]
        ids = [cat['id'] for cat in self.dataset['categories']]
        #print(self.dataset['categories'])
        #print(cats)
        return ids

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM