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 how-to-guides and examples dir #2475

Open
wants to merge 79 commits into
base: release/v2.0.0
Choose a base branch
from

Conversation

samet-akcay
Copy link
Contributor

@samet-akcay samet-akcay commented Dec 20, 2024

📝 Description

  • Add how-to-guides showing tutorials about pre/post processing, evaluation and visualisation
  • Add examples directory to consolidate api/cli/notebook examples

✨ Changes

Select what type of change your PR is:

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🔨 Refactor (non-breaking change which refactors the code base)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔒 Security update

✅ Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • 📋 I have summarized my changes in the CHANGELOG and followed the guidelines for my type of change (skip for minor changes, documentation updates, and test enhancements).
  • 📚 I have made the necessary updates to the documentation (if applicable).
  • 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).

For more information about code review checklists, see the Code Review Checklist.

Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
@samet-akcay samet-akcay changed the base branch from main to release/v2.0.0 December 20, 2024 07:26
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
Signed-off-by: Samet Akcay <[email protected]>
@samet-akcay samet-akcay changed the title 📚Add examples dir 📚Add how-to-guides and examples dir Dec 23, 2024
@samet-akcay samet-akcay requested a review from djdameln December 24, 2024 12:18
# Create a single image item
item = ImageItem(
image=torch.rand(3, 224, 224), # RGB image
gt_label=torch.tensor(0), # Normal (0) or anomalous (1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
gt_label=torch.tensor(0), # Normal (0) or anomalous (1)
gt_label=0 # Normal (0 or False) or anomalous (1 or True)


# Access the data
print(item.image.shape) # torch.Size([3, 224, 224])
print(item.gt_label.item()) # 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
print(item.gt_label.item()) # 0
print(item.gt_label) # tensor(False)

)
for i in range(32)
]
batch = ImageBatch.from_items(items)
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 does not exist

Copy link
Contributor

Choose a reason for hiding this comment

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

There seem to be several other examples in this guide that don't work. Would probably be good to check if these examples are up to date.

train_batch_size: int = 32,
eval_batch_size: int = 32,
num_workers: int = 8,
transform = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

transforms should be removed here and below


- Download/prepare the data
- Set up train/val/test datasets
- Apply transforms
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Apply transforms
- Apply data augmentations


The dataset consists of three main components:

1. **Samples DataFrame**: The heart of each dataset is a DataFrame containing:
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we should mention the dataframe here, given that it may be replaced soon.

dataset = AvenueDataset(
root="./datasets/avenue",
split="test",
transform=transform
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
transform=transform

Comment on lines +71 to +83
train_transform=Compose([
Resize((256, 256)),
RandomHorizontalFlip(),
ToTensor()
]),
val_transform=Compose([
Resize((256, 256)),
ToTensor()
]),
test_transform=Compose([
Resize((256, 256)),
ToTensor()
])
Copy link
Contributor

Choose a reason for hiding this comment

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

This is outdated now that we moved the stage-specific augmentations to the datamodule

Comment on lines +95 to +96
model = Patchcore()

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
model = Patchcore()
model = Patchcore()
print(model.pre_processor.transform)
# Compose(
# Resize(size=[256, 256], interpolation=InterpolationMode.BILINEAR, antialias=True)
# CenterCrop(size=(224, 224))
# Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225], inplace=False)
# )

Comment on lines +98 to +111
model = Patchcore(
pre_processor=PreProcessor(
transform=Compose([
Resize((256, 256)),
ToTensor()
])
)
)

print(model.pre_processor.train_transform)
# Compose(
# Resize(size=[256, 256], interpolation=InterpolationMode.BILINEAR, antialias=False)
# ToTensor()
# )
Copy link
Contributor

Choose a reason for hiding this comment

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

  • train_transform --> transform to reflect most recent design.
  • removed ToTensor to avoid confusing users.
Suggested change
model = Patchcore(
pre_processor=PreProcessor(
transform=Compose([
Resize((256, 256)),
ToTensor()
])
)
)
print(model.pre_processor.train_transform)
# Compose(
# Resize(size=[256, 256], interpolation=InterpolationMode.BILINEAR, antialias=False)
# ToTensor()
# )
model = Patchcore(
pre_processor=PreProcessor(
transform=Resize((256, 256)),
)
)
print(model.pre_processor.transform)
# Resize(size=[256, 256], interpolation=InterpolationMode.BILINEAR, antialias=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants