Giter Site home page Giter Site logo

Comments (8)

hellock avatar hellock commented on May 22, 2024 1

Adding --eval bbox segm will evaluate both bbox AP and mask AP.

from mmdetection.

Minotaur-CN avatar Minotaur-CN commented on May 22, 2024

Thanks for your quick reply!
I used to retrain using "/configs/mask_rcnn_r50_fpn_1x.py"," ./work_dirs/mask_rcnn_r50_fpn_1x/", and
"--eval bbox segm --show"
but only show the detection result, no segmentation result.

from mmdetection.

hellock avatar hellock commented on May 22, 2024

I see, you mean the visualization, not evaluation. The eval argument is for mAP evaluation, and the visualization method is implemented here.

Currently we only visualize the bbox, and will further add mask visualization. You can temporally enable it by replacing the original show_result() with the following method.

def show_result(self,
                    data,
                    result,
                    img_norm_cfg,
                    dataset='coco',
                    score_thr=0.3):
        assert isinstance(result, tuple)
        bbox_result, segm_result = result

        img_tensor = data['img'][0]
        img_metas = data['img_meta'][0].data[0]
        imgs = tensor2imgs(img_tensor, **img_norm_cfg)
        assert len(imgs) == len(img_metas)

        if isinstance(dataset, str):
            class_names = get_classes(dataset)
        elif isinstance(dataset, list):
            class_names = dataset
        else:
            raise TypeError('dataset must be a valid dataset name or a list'
                            ' of class names, not {}'.format(type(dataset)))

        for img, img_meta in zip(imgs, img_metas):
            h, w, _ = img_meta['img_shape']
            img_show = img[:h, :w, :]
            labels = [
                np.full(bbox.shape[0], i, dtype=np.int32)
                for i, bbox in enumerate(bbox_result)
            ]
            labels = np.concatenate(labels)
            bboxes = np.vstack(bbox_result)
            segms = mmcv.concat_list(segm_result)

            inds = np.where(bboxes[:, -1] > score_thr)[0]
            for i in inds:
                color_mask = np.random.randint(0, 256, (1, 3), dtype=np.uint8)
                mask = maskUtils.decode(segms[i]).astype(np.bool)
                img_show[mask] = img_show[mask] * 0.5 + color_mask * 0.5

            mmcv.imshow_det_bboxes(
                img_show,
                bboxes,
                labels,
                class_names=class_names,
                score_thr=score_thr)

from mmdetection.

Minotaur-CN avatar Minotaur-CN commented on May 22, 2024

Thanks.
some error happens.

  1. class 'tensor2imgs' not defined,
    from mmdet.core import tensor2imgs
  2. class 'get_classes' is not defined
    from mmdet.core import get_classes
  3. import np
  4. maskUtils.decode this can not find in your repo. Please update

Thanks!

from mmdetection.

hellock avatar hellock commented on May 22, 2024

Oh I forgot to paste the import-statements.

import numpy as np
import pycocotools.mask as maskUtils
from mmdet.core import tensor2imgs, get_classes

from mmdetection.

Minotaur-CN avatar Minotaur-CN commented on May 22, 2024

Excellent, I can show the segmentation result.
Thanks!

from mmdetection.

Curry1201 avatar Curry1201 commented on May 22, 2024

Hi @Minotaur-CN , I follow the answer from Dr. Chen Kai above. The "Mask_rcnn.py" under mmdetection/mmdet/models/detectors has been modified, and then run the command "python3 tools/test.py configs/mask_rcnn_r50_fpn_1x.py checkpoints/mask_rcnn/mask_rcnn_r50_fpn_1x_20181010-069fa190.pth --show" , why is it still only bbox, what am I doing wrong?

from mmdetection.

hellock avatar hellock commented on May 22, 2024

@Curry1201 You can try the latest version.

from mmdetection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.