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

How to train my own data ? #82

Open
Jialiang123 opened this issue Jul 7, 2023 · 2 comments
Open

How to train my own data ? #82

Jialiang123 opened this issue Jul 7, 2023 · 2 comments

Comments

@Jialiang123
Copy link

Thanks,How to train my own data and implement reasoning on a single graph or multiple graphs?

@romanvelichkin
Copy link

romanvelichkin commented Sep 25, 2023

Code was made to be used only with provided examples. To train on your own data code will require some modifications.

This is a fast solution, not for production usage

  1. create folder for you data in "mvtec_anomaly_detection" folder - you folder must be with "bottle", "cable" etc.
  2. inside your folder orginize data similar to mvtec_anomaly with "good" and other folders.
  3. modify "run_pathcore.py":
    in run > if save_segmentation_images
    before patchcore.utils.plot_segmentation_images add code:
image_save_path = os.path.join(
                    run_save_path, "segmentation_images", dataset_name
                )
                os.makedirs(image_save_path, exist_ok=True)

This will allow you to save segmented images.
4. run patchcore training with bash/cmd command:
python bin/run_patchcore.py --gpu 0 --seed 0 --save_segmentation_images "results_path" patch_core -b wideresnet50 -le layer2 -le layer3 --faiss_on_gpu --pretrain_embed_dimension 1024 --target_embed_dimension 1024 --anomaly_scorer_num_nn 1 --patchsize 3 sampler -p 0.1 approx_greedy_coreset dataset --resize 224 --imagesize 224 -d "your_train_dataset" mvtec "mvtec_anomaly_detection"

"results_path" - path to place where you will save training results
"mvtec_anomaly_detection" - path to place where you keep mvtec datasets (you dataset must be with them)
"your_train_dataset" - name of your dataset (name of your folder in mvtec folder)

  1. If something will go wrong then check errors, carefully read README.md of this repo, check code - some things are missed in READMe.md (like how to properly save segmentation images).

However it's a fast solution, for testing purpose. Patchcore requires a lot of work before it could be used on production.

@wyweather
Copy link

Why didn't I find the mvtec folder? Where should I put my own dataset folder and where to change parameters

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

No branches or pull requests

3 participants