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

About multiscale features and execution speed #90

Open
Ysc-shark opened this issue Feb 22, 2024 · 4 comments
Open

About multiscale features and execution speed #90

Ysc-shark opened this issue Feb 22, 2024 · 4 comments

Comments

@Ysc-shark
Copy link

Hi,thanks for sharing your great work and it really helps me a lot.I have 2 questions to ask.

First,Your paper discusses experiments with 20×+5× multiscale features, showing promising results. However, the downloadable features appear to be only from the single-scale 20× resolution. Could you please provide the 20×+5× features?

Second,I tried running the model on the features you provided, but the model's execution speed is quite slow. It takes nearly 2 days to complete 200 epochs, and the GPU utilization remains around 2% throughout the process. The GPU memory usage is also very low, only consuming a small portion. I'm using a Tesla P100 GPU. Is this normal? How can I improve the execution speed?

Many thanks,
Yu Sicheng

@GeorgeBatch
Copy link
Contributor

GeorgeBatch commented Feb 24, 2024

  1. For multiscale patches and features see: TCGA-lung: please share the training-validation / test split #67
  2. The current code supports 1 slide per batch, so you can not utilise a greater portion of your GPU
  3. Loading features from csv's with pandas, extracting numpy arrays, converting to torch tensors and putting on a GPU is slow. You can go through all csv files once before training and save the features as torch tensors with torch.save() with torhc.float32 data type (so you do not need to convert afterwards). Then, during training, you can load torch tensors with torch.load(). Even faster (but less neat), if you pass your gpu device in a map_location argument of torch.load(), you can load them directly onto your GPU without loading them onto a CPU beforehand.

@Ysc-shark
Copy link
Author

Ysc-shark commented Feb 26, 2024

  1. For multiscale patches and features see: TCGA-lung: please share the training-validation / test split #67
  2. The current code supports 1 slide per batch, so you can not utilise a greater portion of your GPU
  3. Loading features from csv's with pandas, extracting numpy arrays, converting to torch tensors and putting on a GPU is slow. You can go through all csv files once before training and save the features as torch tensors with torch.save() with torhc.float32 data type (so you do not need to convert afterwards). Then, during training, you can load torch tensors with torch.load(). Even faster (but less neat), if you pass your gpu device in a map_location argument of torch.load(), you can load them directly onto your GPU without loading them onto a CPU beforehand.

Thanks for your reply, it's very helpful to me. I have two more questions to ask

  1. Regarding multi-scale patches, in TCGA-lung: please share the training-validation / test split #67, you mentioned encountering issues when downloading TCGA Multiscale features. I've encountered the same problem. Have you solved it?
  2. I'm currently using the scripts deepzoom_tiler.py and compute_feats.py from this project to extract features. However, for the Camelyon16 dataset, as far as I understand, there are slides with both 20× and 40× magnifications. If I want to extract patches with 20×+5× magnifications, is the following command correct?
    python deepzoom_tiler.py -m 0 2 -b 20 -d CAMELYON16 -v tif
    In the readme.md, the author mentioned:
    Camelyon16 consists of mixed magnifications so to reproduce:
    python deepzoom_tiler.py -m 1 -b 20 -d Camelyon16 -v tif
    Does this mean that for the Camelyon16 dataset, m=1 corresponds to 20× resolution?

@GeorgeBatch
Copy link
Contributor

@Ysc-shark

  1. For me, the downloaded multiscale features were split into separate zip files. I extracted the contents and put them together. There were no other complications.
  2. This command python deepzoom_tiler.py -m 0 2 -b 20 -d CAMELYON16 -v tif will extract patches with 20×+5× magnifications under 2 conditions:
    • objective magnification of the scanner is correctly parsed from the slide metadata (usually there, but sometimes is not): Otherwise, the default objective of 20x will be used (you can specify -o argument to change it), which would be incorrect for 40x slides.
      MAG_BASE = self._slide.properties.get(openslide.PROPERTY_NAME_OBJECTIVE_POWER)
    • levels downsamples go as powers of 2 (should be a standard, but is not) and not powers of 4:
      first_level = int(math.log2(float(MAG_BASE)/self._base_mag)) # raw / input, 40/20=2, 40/40=0
      For example, the code assumes that for slide with 20x original magnification, level 0 corresponds to downsample factor of 2^0=1 and keeps 20x magnification, while level 2 corresponds to downsample factor of 2^2=4 making it 5x magnification. However, sometimes scanners produce images with powers of 4, in which case level 0 will still have the downsampling factor of 2^0=1 and keep 20x magnification, while level 1 will have the downsampling factor of 4^1=4 with 5x magnification.

@Ysc-shark
Copy link
Author

@Ysc-shark

  1. For me, the downloaded multiscale features were split into separate zip files. I extracted the contents and put them together. There were no other complications.

  2. This command python deepzoom_tiler.py -m 0 2 -b 20 -d CAMELYON16 -v tif will extract patches with 20×+5× magnifications under 2 conditions:

    • objective magnification of the scanner is correctly parsed from the slide metadata (usually there, but sometimes is not): Otherwise, the default objective of 20x will be used (you can specify -o argument to change it), which would be incorrect for 40x slides.
      MAG_BASE = self._slide.properties.get(openslide.PROPERTY_NAME_OBJECTIVE_POWER)
    • levels downsamples go as powers of 2 (should be a standard, but is not) and not powers of 4:
      first_level = int(math.log2(float(MAG_BASE)/self._base_mag)) # raw / input, 40/20=2, 40/40=0

      For example, the code assumes that for slide with 20x original magnification, level 0 corresponds to downsample factor of 2^0=1 and keeps 20x magnification, while level 2 corresponds to downsample factor of 2^2=4 making it 5x magnification. However, sometimes scanners produce images with powers of 4, in which case level 0 will still have the downsampling factor of 2^0=1 and keep 20x magnification, while level 1 will have the downsampling factor of 4^1=4 with 5x magnification.

Thanks a lot

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