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

Refactor/evaluation task #22

Merged
merged 19 commits into from
Jul 18, 2023
Merged

Refactor/evaluation task #22

merged 19 commits into from
Jul 18, 2023

Conversation

AlessandroPolidori
Copy link
Contributor

@AlessandroPolidori AlessandroPolidori commented Jul 6, 2023

Summary

Describe the purpose of the pull request, including:

  • What problem does it solve?
    Only SegmentationEvaluation extends Evaluation. Also, we need to uniform the evaluation tasks as much as possible.
    Currently they are unnecessarily different (attributes names are different, some use experiment_path while others the model_path).

Also SegmentationEvaluation was not tested, i added two tests (one for multiclass, one for binary).

  • How does it solve the problem?
    All the children evaluations extend the Evaluation class.

  • What are the benefits of the solution?
    Clean code.

  • Reference any relevant issues or pull requests.
    Evaluation Task not used #21

Type of Change

Please select the one relevant option below:

  • Breaking change (fix or feature that would cause existing functionality to not work as expected

Checklist

Please confirm that the following tasks have been completed:

  • I have tested my changes locally and they work as expected. (Please describe the tests you performed.)
  • I have added unit tests for my changes, or updated existing tests if necessary.
  • I have updated the documentation, if applicable.
  • I have installed pre-commit and run locally for my code changes.

@AlessandroPolidori AlessandroPolidori changed the base branch from main to dev July 6, 2023 13:46
Copy link
Contributor

@lorenzomammana lorenzomammana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks pretty good to me and a good improvement in the overall code structure

quadra/tasks/base.py Outdated Show resolved Hide resolved
super().prepare()
self.deployment_model = self.model_path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is not done in the super? We need to manually assign everytime or I'm missing something

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I saw it may be different for plain torch import

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably still set it in super and override the prepare entirely probably, otherwise you need to remember this every time

Copy link
Contributor Author

@AlessandroPolidori AlessandroPolidori Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the only "problem" exists for patchsklearn and sklearnclassif. which don't have a deployment model but backbone + classifier. To move the self.deployment_model = self.model_path in Evaluation i will overwrite the deployment model setter and set classifier and backbone in there. Without really setting a deployment_model object, which is not used in patchsklearn and sklearnclassification.

Copy link
Contributor Author

@AlessandroPolidori AlessandroPolidori Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, see if you like that. Commit: "style: Move self.deployment_model = self.model_path to parent class"
p.s. i know it's not "style", "refactor" would have been better

quadra/tasks/segmentation.py Outdated Show resolved Hide resolved
quadra/tasks/segmentation.py Show resolved Hide resolved
quadra/tasks/segmentation.py Outdated Show resolved Hide resolved
@lorenzomammana lorenzomammana linked an issue Jul 6, 2023 that may be closed by this pull request
@rcmalli
Copy link
Collaborator

rcmalli commented Jul 6, 2023

Amazing job @AlessandroPolidori!

Copy link
Contributor

@lorenzomammana lorenzomammana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to unify the deployment model handling also for sklearn with the caveat of being able to load a backbone directly if it wasn't exported


@deployment_model.setter
def deployment_model(self, model_path: str):
"""Set backbone and classifier."""
try:
self.backbone = OmegaConf.load(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it, why should we be forced to use pytorch here?
I think we should support any kind of model as per other tasks, if torch is not used we don't generate gradients.

Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See commit "fix: Model import in sklearn evaluations now supports .pt and .pth model files" and tell me what you think

return None

@deployment_model.setter
def deployment_model(self, model_path: str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I would probably expect that we can deploy the model without a backbone, but if a deployed model is present it should be the first option

@lorenzomammana lorenzomammana added the enhancement New feature or request label Jul 11, 2023
@lorenzomammana lorenzomammana added this to the v1.1.0 milestone Jul 11, 2023
@AlessandroPolidori AlessandroPolidori marked this pull request as ready for review July 11, 2023 15:21
@rcmalli
Copy link
Collaborator

rcmalli commented Jul 11, 2023

Can we also have a short tutorial starting with training a model and running Evaluation task from command-line or using Python?

Copy link
Contributor

@lorenzomammana lorenzomammana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lorenzomammana lorenzomammana merged commit a473138 into dev Jul 18, 2023
@lorenzomammana lorenzomammana deleted the refactor/evaluation-task branch July 18, 2023 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Evaluation Task not used
3 participants