roboflow / roboflow/supervision

Instance Segmentation Confusion Matrix

Open
#238 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
50.9k
Forks
4.8k
Avg merge
1d 12h
Merged PRs (30d)
85

Description

Search before asking
  • I have searched the Supervision issues and found no similar feature requests.
Description

The current evaluation api supports confusion matrix only for object detection. Giving a view on how the model is performing for instance segmentation per class is desirable.

Slight change in API expected:

@dataclass
class ConfusionMatrix:
    matrix: np.ndarray
    segmentationMatrix: np.ndarray
    classes: List[str]
    conf_threshold: float
    iou_threshold: float

    @classmethod
    def from_detections(
        cls,
        predictions: List[sv.Detections],
        target: List[sv.Detections],
        classes: List[str],
        conf_threshold: float = 0.3,
        iou_threshold: float = 0.5
    ) -> ConfusionMatrix:
        pass

   @classmethod
    def benchmark(
        cls,
        dataset: sv.DetectionDataset,
        callback: Callable[[np.ndarray], sv.Detections],
        conf_threshold: float = 0.3,
        iou_threshold: float = 0.5
    ) -> ConfusionMatrix:
        pass

    def plot(self, target_path: str) -> None:
        pass

Discussion points:

  1. Note that I'm not changing the previous name matrix to detectionMatrix for backward compatibility. If we believe it's not necessary and brings readability for the long term, can make that change.
  2. Should this be an opt-in feature. Not sure what the user behaviour is. If the 90 percentile user wants both let's not. If it's the other way around, we can instead make a separate confusion matrix class called SegmentationConfusionMatrix
Use case

No response

Additional

No response

Are you willing to submit a PR?
  • Yes I'd like to help by submitting a PR!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing object-detection confusion-matrix evaluation API and its from_detections, benchmark, and plot entry points. Review the eight-comment discussion before choosing the API shape; done means instance-segmentation results can be evaluated per class and represented and plotted without breaking the existing matrix behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.