nadeemlab / DeepLIIF

Deep Learning Inferred Multiplex ImmunoFluorescence for IHC Image Quantification (https://deepliif.org) [Nature Machine Intelligence'22, CVPR'22, MICCAI'23, Histopathology'23, MICCAI'24]
https://deepliif.org
Other
169 stars 63 forks source link

Updated Model Training #42

Open wendywangwwt opened 2 months ago

wendywangwwt commented 2 months ago

This PR includes a couple of major updates for model training:

  1. Implementation of Attention UNet compatible with the current framework: now attention UNet is available to be used as a network architecture (unet_512_attention)
  2. Validation loss and metrics calculation during training: with flag --with-val, validation losses (same types of loss as training) and metrics (cell count metrics through postprocess function) can be calculated as training goes, and the corresponding support in visdom visualizer is also implemented
    • At the moment cell count metrics are only calculated for DeepLIIF models.

Others

Notes:

dir_img = 'Datasets/Sample_Dataset/val' get_cell_count_metrics(dir, model='DeepLIIF', tile_size=512)

The code generates the `metrics.json` file for the validation data under the same directory as the images.

- To run multiple tests in parallel (e.g., run latest/ext/sdg at the same time), make sure to use different tmp directory in `--basetemp`, so that the pytest processes will not delete or modify a temp folder created or used by another process. For example:

pytest -v -s --basetemp=../tmp/latest --model_type latest 2>&1 | tee ../log/pytest_latest_20240808.log pytest -v -s --basetemp=../tmp/ext --model_type ext 2>&1 | tee ../log/pytest_ext_20240808.log pytest -v -s --basetemp=../tmp/sdg --model_type sdg 2>&1 | tee ../log/pytest_sdg_20240808.log

wendywangwwt commented 2 months ago

Test environment:

All tests passed. Ran ext tests for twice and I did not see GPU OOM failure. Test logs are in onedrive folder DeepLIIF PR#42 attachments.