Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluation / Testing Step for COCO Object detection #20389

Closed
shanalikhan opened this issue Nov 4, 2024 · 0 comments
Closed

Evaluation / Testing Step for COCO Object detection #20389

shanalikhan opened this issue Nov 4, 2024 · 0 comments
Labels
needs triage Waiting to be triaged by maintainers refactor

Comments

@shanalikhan
Copy link

shanalikhan commented Nov 4, 2024

Outline & Motivation

I've written the code from the link

import numpy as np

class CocoDNN(L.LightningModule):
    def __init__(self):
        super().__init__()
        self.model = models.detection.fasterrcnn_mobilenet_v3_large_fpn(weights="DEFAULT")

    def forward(self, images, targets=None):
        return self.model(images, targets)

    def training_step(self, batch, batch_idx):
        imgs, annot = batch
        #print(f"Batch :{batch_idx}")

        batch_losses = []
        for img_b, annot_b in zip(imgs, annot):
            #print(len(img_b), len(annot_b))
            if len(img_b) == 0:
                continue
            loss_dict = self.model(img_b, annot_b)
            losses = sum(loss for loss in loss_dict.values())
            #print(losses)
            batch_losses.append(losses)

        batch_mean  = torch.mean(torch.stack(batch_losses))
        #print(batch_mean)
        self.log('train_loss', batch_mean)

        #print(imgs[0])
        #print(' ----',annot)
        #loss_dict = self.model(img_b, annot_b)
        #losses = sum(loss for loss in loss_dict.values())
        #self.log('train_loss', losses)
        return batch_mean

    def configure_optimizers(self):
        return optim.SGD(self.parameters(), lr=0.001, momentum=0.9, weight_decay=0.0005)

I want to evaluate it using evaluation_step and testing_step. Can you guide me the code refactor do that

Images are 512x512 and coco format.

Pitch

No response

Additional context

No response

cc @justusschock @awaelchli

@shanalikhan shanalikhan added needs triage Waiting to be triaged by maintainers refactor labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Waiting to be triaged by maintainers refactor
Projects
None yet
Development

No branches or pull requests

1 participant