Skip to content

[RFC] Metrics Paramater in training loops #93

@oke-aditya

Description

@oke-aditya

🚀 Feature

Slightly important as engines are concerned here 😅
Metrics parameter in training.

Motivation

What currently we do in train_step, val_step or fit API returns a dictionary by calculating metrics from torchvision and return metrics (but not predictions).
This hardcodes the API and is trouble.
Metrics param which will open up this API.
Currently train_step will always return metrics, and not return results/model outputs.
Let's add a param metrics which will work as follows.

Pitch

For Detection models in PyTorch Trainers, the Param would work as follows.

metrics: str = None
if metrics is None:
    # Just output what model does and return it.
    # Now people can manually calculate and play around as they like 
    # We do not do PostProcessing, this can be used by the user which we provide. 
elif metrics == "native":
    # Use the torchvision native metrics which we have now.
    # We can expect these to improve over time or adopt lightning metrics here.

## Maybe if we don't get this dependency
elif metrics = "coco":
    # Calculate COCO API metrics (we do the PostProcessing if needed)

Since PyTorch Lightning API is completely decoupled from PyTorch. People can already subclass it and use PL Metrics.
E.g.

class CustomTraining(lit_frcnn):
        def validation_step(self, batch, batch_idx):
            images, targets = batch
            targets = [{k: v for k, v in t.items()} for t in targets]

            out = self.model(images) 
            # Do whatever metrics you like !

Metrics with lIghtning is easer, we can use PL metrics and calculate these on fly with a param in Trainer
Not sure about this but possible easily.

Alternatives

This is open to discussion and really a neat solution can be a major feature upgrade.

Additional context

This will solve lot of issues like #62 ,
Be able to use COCO API for detection. We should not have this dependency. So COCO is still a little confusion,
with metrics None, people can postprocess (which we provide) and use COCO API.

cc @zlapp @zhiqwang @hassiahk

Metadata

Metadata

Assignees

No one assigned

    Labels

    Medium PriorityShould be addressed in few daysenhancementNew feature or requestfeatureA new feature request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions