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

Train DINO from scratch #1

Open
xiaoyatang opened this issue Nov 29, 2024 · 4 comments
Open

Train DINO from scratch #1

xiaoyatang opened this issue Nov 29, 2024 · 4 comments

Comments

@xiaoyatang
Copy link

Dear authors,

Thanks for your work! A simple question: why do we need a dino_scratch.pth for training DINO from scratch? Isn't it from scratch?
Running case:"
python compute_feats.py
--embedder=DINO
--num_classes=2048
--backbone=vit_small
--weights=embedders/dino_scratch.pth
--version_name=dino_scratch"

@da-nial
Copy link
Collaborator

da-nial commented Nov 29, 2024

Thanks for the question! Let me clarify:

The dino_scratch.pth file contains the weights of the DINO model after it has been trained from scratch on the patches. While DINO is indeed trained "from scratch", we need to save these trained weights so we can use them later for feature extraction. The compute_feats.py script you referenced is the step that comes after training - it uses the already-trained DINO model (i.e. embedder, loaded from dino_scratch.pth) to extract features (embeddings) from patches.

@xiaoyatang
Copy link
Author

Thanks for the question! Let me clarify:

The dino_scratch.pth file contains the weights of the DINO model after it has been trained from scratch on the patches. While DINO is indeed trained "from scratch", we need to save these trained weights so we can use them later for feature extraction. The compute_feats.py script you referenced is the step that comes after training - it uses the already-trained DINO model (i.e. embedder, loaded from dino_scratch.pth) to extract features (embeddings) from patches.

Hi Danial,

Thank you for your prompt reply! That helps a lot! I have 3 more questions:

  1. Did you provide the code for training the embedded from scratch on patches?
  2. I am using my own patches generated from Camelyon16. Does the tile_label.csv you generated in 'deepzoom_tiler_camelyon16.py' contain labels for all patches or tiles?
  3. What does the 'bags' mean in compute_feats.py? In your provided dataset structure: {DATASETS_PATH}/{args.dataset}/'single/{args.fold}'/{train, validation, test}/{0_normal,1_tumor} I can't see what is 'bags'.

@da-nial
Copy link
Collaborator

da-nial commented Nov 30, 2024

Hi! Thanks for your follow-up questions. Let me address each one:

  1. For training DINO from scratch, we actually don't provide the code in our repository because the original DINO repository implementation is sufficient. You can follow their training procedure as mentioned in this section. We only provide the code for our adapter-based methods (DINO with Adapter, MAE with Adapter).
  2. Yes, the tile_label.csv generated by deepzoom_tiler_camelyon16.py contains labels for all patches/tiles. This file is necessary if you want to evaluate patch-level metrics (e.g. accuracy or AUC) for patch classification and ROI detection.
  3. The term "bags" comes from treating WSI classification as a Multiple Instance Learning (MIL) problem. In this context:
    • A "bag" refers to a single WSI
    • The "instances" are the individual patches/tiles from that slide
      we sometimes use these terms interchangeably in the code: Slide/Bag and Instance/Patch/Tile.

Please let me know if you have any other questions!

@xiaoyatang
Copy link
Author

Hi! Thanks for your follow-up questions. Let me address each one:

  1. For training DINO from scratch, we actually don't provide the code in our repository because the original DINO repository implementation is sufficient. You can follow their training procedure as mentioned in this section. We only provide the code for our adapter-based methods (DINO with Adapter, MAE with Adapter).

  2. Yes, the tile_label.csv generated by deepzoom_tiler_camelyon16.py contains labels for all patches/tiles. This file is necessary if you want to evaluate patch-level metrics (e.g. accuracy or AUC) for patch classification and ROI detection.

  3. The term "bags" comes from treating WSI classification as a Multiple Instance Learning (MIL) problem. In this context:

    • A "bag" refers to a single WSI
    • The "instances" are the individual patches/tiles from that slide
      we sometimes use these terms interchangeably in the code: Slide/Bag and Instance/Patch/Tile.

Please let me know if you have any other questions!

Thank you so much!!

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

2 participants