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

➕ Add FastFlow Model #336

Merged
merged 30 commits into from
Jun 7, 2022
Merged

➕ Add FastFlow Model #336

merged 30 commits into from
Jun 7, 2022

Conversation

samet-akcay
Copy link
Contributor

Description

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

Copy link
Contributor

@djdameln djdameln left a comment

Choose a reason for hiding this comment

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

Thanks! I have a few comments, mainly minor

anomalib/models/fastflow/__init__.py Show resolved Hide resolved
image_size: 256 # options: [256, 256, 448, 384] - for each supported backbone
train_batch_size: 32
test_batch_size: 32
num_workers: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

num_workers is usually set to a higher default value, for the other models it's 36.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for spotting this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like its not consistent across algos.patchcore is 0 as well. I'll fix them all


self.feature_extractor.eval()
if isinstance(self.feature_extractor, VisionTransformer):
x = self.feature_extractor.patch_embed(x)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does pylint allow single letter variable names?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I temporarily ignore that in L192. As I said, this FastFlowModel would require some refactor later.

)
self.anomaly_map_generator = AnomalyMapGenerator(input_size=input_size)

def forward(self, x: Tensor) -> Union[Tuple[List[Tensor], List[Tensor]], Tensor]:
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is a bit hard to read. Maybe you could split it into several sub-methods. Something like:

if isinstance(self.feature_extractor, VisionTransformer):
    features = self.get_transformer_features(x)
elif isinstance(self.feature_extractor, Cait):
    features = self.get_cait_features(x)
else:
    features = self.feature_extractor(x)
    
hidden_variables = self.get_hidden_variables(features)

@samet-akcay samet-akcay marked this pull request as ready for review June 1, 2022 10:27
Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 left a comment

Choose a reason for hiding this comment

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

Thanks! Only a few minor comments

anomalib/models/fastflow/README.md Outdated Show resolved Hide resolved
anomalib/models/fastflow/config.yaml Outdated Show resolved Hide resolved
anomalib/models/fastflow/lightning_model.py Outdated Show resolved Hide resolved
@samet-akcay samet-akcay changed the title Add FastFlow Model ➕ Add FastFlow Model Jun 1, 2022
("dfkde", False),
("dfm", False),
("stfpm", False),
("fastflow", False),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this will work as the performance thresholds for fastflow haven't been updated in the performance threshold file.

Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 left a comment

Choose a reason for hiding this comment

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

One minor issue but that can be addressed later. LGTM

| Transistor | 0.938 | 0.979 | 0.993 | 0.983 |
| Wood | 0.978 | 0.992 | 0.979 | 0.989 |
| Zipper | 0.878 | 0.951 | 0.981 | 0.977 |
| Average | | | | |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add the average score? Also, a minor issue but this format is a bit different from our other models (rows <-> columns). Maybe for consistency we should decide on a single format. Maybe this can be addressed in a different PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are some categories that I need to run again to exactly produce the numbers, which is the reason why I left it blank. As agreed, I could add these later.

Regarding the table format, I would prefer this because 15 MVTec categories doesn't fit to the screen when they are placed into columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could perhaps modify all the tables once we have all the benchmark results merged

@samet-akcay samet-akcay merged commit 8adfc6c into development Jun 7, 2022
@samet-akcay samet-akcay deleted the feature/sa/fastflow branch June 7, 2022 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FastFlow Model
3 participants