-
Notifications
You must be signed in to change notification settings - Fork 635
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
1 epoch #67
Comments
Hi @sequoiagrove, PADIM algorithm doesn't require any CNN-based learning. It rather uses the CNN to extract the features of the training set, which is then used to fit a multivariate gaussian model. We therefore use 1 epoch to go through the entire training set and extract the features. |
For the warning that there is no optimiser is also related to the above statement. Since we use the CNN only to extract the features, there is no optimiser set for the CNN training. |
that's what I thought. Nevertheless, Impressive work :) |
This is a PR we just merged this morning, and haven't thoroughly tested yet. Maybe @ashwinvaidya17 could provide a better insight here.
The models don't use annotated images, so adding them wouldn't help. To find the small anomalies, you could either increase the image size or configure tiling from the config file. This is mainly because when a large image is resized into 256x256, detecting small anomalies becomes even smaller and detecting them becomes almost impossible. Using larger input or tiled input image could provide better performance. In addition, our hyper-parameter optimisation tool will soon become publicly available so that parameter tuning could also be done to find the best parametrisation for custom datasets. |
ah ok , I checked out this friday. Now I re-checked out and now I get good maps out of the box, as long I reverted lightning back to 1.3.6 , put number of workers down to a reasonable amount, and add cv2.waitKey() after imshow. |
Yeah, there is a PR that bumps up the lightning version to 1.6.0dev, but there are some breaking changes, and might take some time to merge this. Good catch for |
Also found that line 149 in torch.py (inferencer) has to be 👍 and patchcore cannot train at the moment due to datatypes: | Name | Type | Params0 | image_threshold | AdaptiveThreshold | 0
|
Thanks for reporting these! |
@sequoiagrove Thanks for reporting these 😀 |
could it be confudsion between torch install that happened when I struggled to enable my GPU? pytorch 1.10.1 py3.8_cuda11.3_cudnn8_0 pytorch |
@sequoiagrove Could be. That's another issue that's been on our list for some time 🙃 |
fixed it: |
patchcore inference: mixed datatypes. Brilliant usage of union btw :) meta_data is: {'image_threshold': tensor(2.0865), 'pixel_threshold': tensor(2.8785), 'min': tensor(0.7478), 'max': tensor(4.2167), 'image_shape': (1024, 1024)} anomalymap is tensor and pred_score is array. if I run padim, both of them are tensors. |
Found the issue. I prnted the data types trough out the inference. in model.py score and map is tensor all the way, it is in the deploy/torch.py you ask "isinstance(map, tensor)" . andboth of them are, but it is false because it is two tensors, not just one. and the code for false is to convert pred_score to numpy. but anomaly_map is assumed to be numpy already. the metadata is still tensors so I cant just also convert the map to numpy. |
this works for all three models I trained padim, patchcore and stfpm:
|
I tried to make a new environment to install the exact versions in your requirements. I had to make the same fixes as above to get patchcore working. DATALOADER:0 TEST RESULTS |
@sequoiagrove It is possible that some metrics might have diverged from when we collected the results. There is a plan to re-evaluate all the algorithms. Also, a benchmarking script is in PR state which will help gather results but merging this is pushed back before a refactor we are planning. Here is a tip, if you want to log anomaly images, you can modify |
I tried this other patchcore repo [ https://github.com/hcw-00/PatchCore_anomaly_detection ]on mvtec/screws and it gives me: {'img_auc': 0.5911047345767575, 'pixel_auc': 0.9048583939897462} and rather random anomaly maps as well.. |
Thanks for reporting this discrepancy @sequoiagrove. We'll investigate the benchmarks |
Is it meant to be only one epoch in training?
Your config files state 1 epoch, is that just as quick example?
I tried to train PADIM for 10 on mvtec leather and wood and the metrics stay the same anyway, so it seems nothing as gained by training more.
Lightning module also warn that there is no optimizer so I guess train only finds the correct thresholds and that takes 1 epoch.
The text was updated successfully, but these errors were encountered: