Replies: 15 comments 5 replies
-
Thanks for submitting this issue! It has been added to our triage queue. A maintainer will review it shortly. |
Beta Was this translation helpful? Give feedback.
-
Can you show the script you used? Also in markdown you can format your code: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks Try it! |
Beta Was this translation helpful? Give feedback.
-
Hello, for PatchCore you can change number of channels from default 3 to 1 here by adding anomalib/src/anomalib/models/components/feature_extractors/timm.py Lines 120 to 127 in 90e1192 |
Beta Was this translation helpful? Give feedback.
-
def trainGray(): v2.Grayscale(),This method is useless File "D:\BaiduNetdiskDownload\anomalib\anomalib-2.0.0\src\anomalib\data\validators\torch\image.py", line 518, in validate_image |
Beta Was this translation helpful? Give feedback.
-
Ah I see, you are wanting to train with Grayscale images. So your The feature extractor of the model must therefore accept grayscale images, as @abc-125 suggested:
|
Beta Was this translation helpful? Give feedback.
-
This is because of the data validations I guess. anomalib/src/anomalib/data/validators/torch/image.py Lines 516 to 518 in 90e1192 Maybe we could remove this validation? |
Beta Was this translation helpful? Give feedback.
-
anomalib/src/anomalib/data/validators/torch/image.py Lines 479 to 486 in 90e1192 The whole function expects RGB Images, does the rest of anomalib depend on the shape If not, then as you say don't validate for RGB? If yes, then you can also do |
Beta Was this translation helpful? Give feedback.
-
We might need to validate this :) But you are right, |
Beta Was this translation helpful? Give feedback.
-
the sanme error |
Beta Was this translation helpful? Give feedback.
-
no |
Beta Was this translation helpful? Give feedback.
-
what do you mean by no? can you elaborate ? |
Beta Was this translation helpful? Give feedback.
-
Not only this one needs to be changed, there are other things that need to be changed |
Beta Was this translation helpful? Give feedback.
-
Have you tried this option |
Beta Was this translation helpful? Give feedback.
-
(model): PatchcoreModel( |
Beta Was this translation helpful? Give feedback.
-
Yes, but it should be gray scale, not rgb? Have you checked the channels? They should be the same |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Your Question
D:\anaconda3\envs\ultralytics\python.exe D:\BaiduNetdiskDownload\anomalib\anomalib-2.0.0\PatchcoreTrain.py
D:\anaconda3\envs\ultralytics\lib\site-packages\openvino\runtime_init_.py:10: DeprecationWarning: The
openvino.runtime
module is deprecated and will be removed in the 2026.0 release. Please replaceopenvino.runtime
withopenvino
.warnings.warn(
D:\anaconda3\envs\ultralytics\lib\site-packages\timm\models\layers_init_.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
warnings.warn(f"Importing from {name} is deprecated, please import via timm.layers", FutureWarning)
D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\utilities\parsing.py:209: Attribute 'pre_processor' is an instance of
nn.Module
and is already saved during checkpointing. It is recommended to ignore them usingself.save_hyperparameters(ignore=['pre_processor'])
.GPU available: False, used: False
TPU available: False, using: 0 TPU cores
HPU available: False, using: 0 HPUs
D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\core\optimizer.py:183:
LightningModule.configure_optimizers
returnedNone
, this fit will run with no optimizer| Name | Type | Params | Mode
0 | pre_processor | PreProcessor | 0 | train
1 | post_processor | PostProcessor | 0 | train
2 | evaluator | Evaluator | 0 | train
3 | model | PatchcoreModel | 24.9 M | train
24.9 M Trainable params
0 Non-trainable params
24.9 M Total params
99.450 Total estimated model params size (MB)
19 Modules in train mode
174 Modules in eval mode
D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\trainer\connectors\data_connector.py:425: The 'train_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the
num_workers
argumentto
num_workers=15in the
DataLoaderto improve performance. D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\trainer\connectors\data_connector.py:425: The 'val_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the
num_workersargument
tonum_workers=15
in theDataLoader
to improve performance.Epoch 0: 0%| | 0/14 [00:00<?, ?it/s] Traceback (most recent call last):
File "D:\BaiduNetdiskDownload\anomalib\anomalib-2.0.0\PatchcoreTrain.py", line 158, in
train()
File "D:\BaiduNetdiskDownload\anomalib\anomalib-2.0.0\PatchcoreTrain.py", line 25, in train
engine.fit(datamodule=datamodule, model=model)
File "D:\BaiduNetdiskDownload\anomalib\anomalib-2.0.0\src\anomalib\engine\engine.py", line 416, in fit
self.trainer.fit(model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\trainer\trainer.py", line 561, in fit
call._call_and_handle_interrupt(
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\trainer\call.py", line 48, in _call_and_handle_interrupt
return trainer_fn(*args, **kwargs)
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\trainer\trainer.py", line 599, in _fit_impl
self._run(model, ckpt_path=ckpt_path)
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\trainer\trainer.py", line 1012, in _run
results = self._run_stage()
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\trainer\trainer.py", line 1056, in _run_stage
self.fit_loop.run()
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\loops\fit_loop.py", line 216, in run
self.advance()
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\loops\fit_loop.py", line 455, in advance
self.epoch_loop.run(self._data_fetcher)
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\loops\training_epoch_loop.py", line 150, in run
self.advance(data_fetcher)
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\loops\training_epoch_loop.py", line 303, in advance
call._call_callback_hooks(trainer, "on_train_batch_start", batch, batch_idx)
File "D:\anaconda3\envs\ultralytics\lib\site-packages\lightning\pytorch\trainer\call.py", line 227, in _call_callback_hooks
fn(trainer, trainer.lightning_module, *args, **kwargs)
File "D:\BaiduNetdiskDownload\anomalib\anomalib-2.0.0\src\anomalib\pre_processing\pre_processor.py", line 91, in on_train_batch_start
batch.image, batch.gt_mask = self.transform(batch.image, batch.gt_mask)
File "D:\BaiduNetdiskDownload\anomalib\anomalib-2.0.0\src\anomalib\data\dataclasses\generic.py", line 128, in set
value = validator(value)
File "D:\BaiduNetdiskDownload\anomalib\anomalib-2.0.0\src\anomalib\data\validators\torch\image.py", line 518, in validate_image
raise ValueError(msg)
ValueError: Image must have 3 channels, got 1.
Epoch 0: 0%| | 0/14 [00:00<?, ?it/s]
Process finished with exit code 1
Forum Check
Beta Was this translation helpful? Give feedback.
All reactions