Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

If set optional classes on MscocoObjectDetection then fail to instantiate. #523

Closed
takecore opened this issue Oct 15, 2019 · 1 comment
Closed

Comments

@takecore
Copy link
Contributor

takecore commented Oct 15, 2019

at version: v0.12.0

I want to use optional classes on MscocoObjectDetection like below code.

https://github.com/blue-oil/blueoil/blob/master/lmnet/lmnet/datasets/mscoco.py#L140

class MscocoObjectDetection(ObjectDetectionBase):
-     classes = DEFAULT_CLASSES
---
+     classes = ["person"]

So I checked it with test like below code.

# lmnet/tests/lmnet_tests/datasets_tests/test_mscoco.py
from lmnet.datasets.mscoco import MscocoObjectDetection, DEFAULT_CLASSES


def test_mscoco_object_detection_optional_classes():
    classes = [DEFAULT_CLASSES[0]]
    MscocoObjectDetection.classes = classes
    dataset = MscocoObjectDetection(subset='train')

And got error like below.

$ pytest tests/lmnet_tests/datasets_tests/test_mscoco.py

________________________________________________________________ test_mscoco_object_detection_optional_classes ________________________________________________________________

    def test_mscoco_object_detection_optional_classes():
        classes = [DEFAULT_CLASSES[0]]
        MscocoObjectDetection.classes = classes
>       dataset = MscocoObjectDetection(subset='train')

tests/lmnet_tests/datasets_tests/test_mscoco.py:25:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
lmnet/datasets/mscoco.py:164: in __init__
    self._init_files_and_annotations()
lmnet/datasets/mscoco.py:249: in _init_files_and_annotations
    self.files, self.annotations = self._files_and_annotations()
lmnet/datasets/mscoco.py:244: in _files_and_annotations
    gt_boxes_list = [self._gt_boxes_from_image_id(image_id) for image_id in image_ids]
lmnet/datasets/mscoco.py:244: in <listcomp>
    gt_boxes_list = [self._gt_boxes_from_image_id(image_id) for image_id in image_ids]
lmnet/datasets/mscoco.py:232: in _gt_boxes_from_image_id
    for annotation in annotations:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <lmnet.datasets.mscoco.MscocoObjectDetection object at 0x7f23cd31f588>, cat_id = 28

    @functools.lru_cache(maxsize=None)
    def coco_category_id_to_lmnet_class_id(self, cat_id):
        target_class = self.coco.loadCats(cat_id)[0]['name']
>       class_id = self.classes.index(target_class)
E       ValueError: 'umbrella' is not in list

lmnet/datasets/mscoco.py:222: ValueError
@iizukak
Copy link
Member

iizukak commented Oct 31, 2019

#525 was merged.

@iizukak iizukak closed this as completed Oct 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants