-
Notifications
You must be signed in to change notification settings - Fork 681
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
Feature/rd++ #2386
base: main
Are you sure you want to change the base?
Feature/rd++ #2386
Conversation
This is test code (I used the recommended epochs from the authors.): import logging
from anomalib import TaskType
from anomalib.data import MVTec
from anomalib.engine import Engine
from anomalib.models import RevisitingReverseDistillation
from lightning.pytorch.callbacks import EarlyStopping, ModelCheckpoint
# configure logger
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
# Define the number of epochs for each category
epoch_mapping = {
'carpet': 10,
'leather': 10,
'grid': 260,
'tile': 260,
'wood': 100,
'cable': 240,
'capsule': 300,
'hazelnut': 160,
'metal_nut': 160,
'screw': 280,
'toothbrush': 280,
'transistor': 300,
'zipper': 300,
'pill': 200,
'bottle': 200,
}
# datasets = ['screw', 'pill', 'capsule', 'carpet', 'grid', 'tile', 'wood', 'zipper', 'cable', 'toothbrush', 'transistor',
# 'metal_nut', 'bottle', 'hazelnut', 'leather']
# datasets = ['carpet']
datasets = ['bottle', 'hazelnut', 'leather']
for dataset in datasets:
logger.info(f"================== Processing dataset: {dataset} ==================")
task = TaskType.SEGMENTATION
datamodule = MVTec(
root="../datasets/MVTec",
category=dataset,
image_size=256,
train_batch_size=32,
eval_batch_size=32,
num_workers=0,
task=task,
)
model = RevisitingReverseDistillation()
callbacks = [
ModelCheckpoint(
mode="max",
monitor="pixel_AUROC",
),
EarlyStopping(
monitor="pixel_AUROC",
mode="max",
patience=3,
),
]
# Get the number of epochs for the current dataset
num_epochs = epoch_mapping.get(dataset, 100) # Default to 100 if not found
logger.info(f"Using {num_epochs} epochs for dataset: {dataset}")
engine = Engine(
max_epochs=num_epochs,
check_val_every_n_epoch=3,
callbacks=callbacks,
pixel_metrics=["AUROC", "PRO"], image_metrics=["AUROC", "PRO"],
accelerator="auto", # <"cpu", "gpu", "tpu", "ipu", "hpu", "auto">,
devices=1,
logger=False,
)
logger.info(f"================== Start training for dataset: {dataset} ==================")
engine.fit(datamodule=datamodule, model=model)
logger.info(f"================== Start testing for dataset: {dataset} ==================")
engine.test(datamodule=datamodule, model=model) This is the result compared to
|
β¦ic skeletal structure of the code. Signed-off-by: Jinyao Chen <cjy513203427@gmail.com>
Signed-off-by: Jinyao Chen <cjy513203427@gmail.com>
Signed-off-by: Jinyao Chen <cjy513203427@gmail.com>
* Add datumaro annotation dataloader Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com> * Update changelog Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com> * Add examples Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com> --------- Signed-off-by: Ashwin Vaidya <ashwinnitinvaidya@gmail.com>
* add notebook 701e_aupimo_advanced_iv on load/save and statistical comparisons Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com> * make `AUPIMOResult.num_thresholds` optional Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com> * add aupimo notebook advanced iv (load/save and statistical tests) Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com> * simplify cite us and mention intal Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com> * fix readme Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com> --------- Signed-off-by: jpcbertoldo <24547377+jpcbertoldo@users.noreply.github.com> Co-authored-by: Samet Akcay <samet.akcay@intel.com>
Signed-off-by: Jinyao Chen <cjy513203427@gmail.com>
a87a1be
to
0221691
Compare
Check out this pull request onΒ See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@cjy513203427 thanks a lot for your contribution! regarding the noise, it could be a torchvision transform such as anomalib/src/anomalib/models/image/patchcore/lightning_model.py Lines 131 to 143 in c00e101
|
Hey guys, do you have any ETA on this? |
π Description
β¨ Changes
Select what type of change your PR is:
β Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.
I re-implemented part of the RD++ algorithm. It is based on reverse distillation. I added
self-supervised optimal transport loss
,reconstruction loss
,contrast loss
andMultiscale projection layers
based onπ Paperπ§βπ» Code
Some things are missing: The authors use a customised dataloader and noise.py for MVTEC dataset. However, I don't find any noise definition in Anomalib. Perlin noise is something else. Should I add a noise function in mvtec.py which could affect other functions or create a customised dataloader for RD++?