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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃敤 Increase inference + openvino support #122

Merged
merged 4 commits into from
Mar 8, 2022

Conversation

ashwinvaidya17
Copy link
Collaborator

Description

Known Issues

  • Classification models still produce unnormalized scores.

Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the pre-commit style and check guidelines of this project.
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

Tests

  • Since inference tests run on lightly
    image

@ashwinvaidya17 ashwinvaidya17 added the Bug Something isn't working label Feb 25, 2022
layer_outputs = torch.cat(list(layer_outputs.values())).detach()
return layer_outputs

def fit_normality_model(self, embeddings: List[Tensor]):
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 prefer this is called just fit. During its usage, it would just be self.model.fit(embeddings


from anomalib.models.components import AnomalyModule, FeatureExtractor

from .normality_model import NormalityModel


class DfkdeModel(nn.Module):
"""DFKDR model.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: DFKDE

feature_vector = self.get_features(batch)
return self.normality_model.predict(feature_vector.view(feature_vector.shape[:2]))


class DfkdeLightning(AnomalyModule):
"""DFKDE: Deep Featured Kernel Density Estimation.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: Deep Feature

filter_count=hparams.model.max_training_points,
threshold_steepness=self.threshold_steepness,
threshold_offset=self.threshold_offset,
backbone = getattr(torchvision.models, hparams.model.backbone)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could create the backbone inside DfkdeModel and just pass the hparams.model.backbone to the constructor of that class. That would be more in line with other models (see Padim for example).

self.feature_extractor = FeatureExtractor(backbone=self.backbone(pretrained=True), layers=["avgpool"]).eval()

self.dfm_model = DFMModel(n_comps=hparams.model.pca_level, score_type=hparams.model.score_type)
backbone = getattr(torchvision.models, hparams.model.backbone)
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, let's pass the string from the hparams and then instantiate the backbone inside the pytorch model.

@samet-akcay samet-akcay self-requested a review March 8, 2022 14:52
@samet-akcay samet-akcay merged commit 0d23715 into development Mar 8, 2022
@samet-akcay samet-akcay deleted the ashwin/openvino_support branch March 8, 2022 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ganomaly inference.py error
3 participants