Skip to content
Snippets Groups Projects
Commit 86fd2f9b authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[configs.models_datasets] Delete, move densenet-rs to models directory; Update some of the docs

parent 513bed9d
No related branches found
No related tags found
1 merge request!6Making use of LightningDataModule and simplification of data loading
Pipeline #76742 failed
......@@ -8,7 +8,7 @@ Preset Configurations
---------------------
This module contains preset configurations for baseline CNN architectures and
datasets.
datamodules.
Models
......@@ -22,114 +22,79 @@ Models
ptbench.configs.models.alexnet_pretrained
ptbench.configs.models.densenet
ptbench.configs.models.densenet_pretrained
ptbench.configs.models.densenet_rs
ptbench.configs.models.logistic_regression
ptbench.configs.models.pasa
ptbench.configs.models.signs_to_tb
ptbench.configs.models_datasets.densenet_rs
.. _ptbench.configs.datasets:
.. _ptbench.configs.datamodules:
Datasets
========
Preset Datamodules
==================
Datasets include iterative accessors to raw data
(:ref:`ptbench.setup.datasets`) including data pre-processing and augmentation,
if applicable. Use these datasets for training and evaluating your models.
Datamodules include iterative accessors to raw data
(:ref:`ptbench.setup.databases`) including data pre-processing to a minimum
input standard, if applicable. Use these datamodules for training and evaluating
your models.
.. autosummary::
:toctree: api/configs/datasets
:toctree: api/configs/datamodules
:template: config.rst
ptbench.configs.datasets.indian.default
ptbench.configs.datasets.indian.rgb
ptbench.configs.datasets.indian_RS.default
ptbench.configs.datasets.mc_ch.default
ptbench.configs.datasets.mc_ch.rgb
ptbench.configs.datasets.mc_ch_RS.default
ptbench.configs.datasets.mc_ch_in.default
ptbench.configs.datasets.mc_ch_in.rgb
ptbench.configs.datasets.mc_ch_in_RS.default
ptbench.configs.datasets.mc_ch_in_11k.default
ptbench.configs.datasets.mc_ch_in_11k.rgb
ptbench.configs.datasets.mc_ch_in_11k_RS.default
ptbench.configs.datasets.mc_ch_in_11kv2.default
ptbench.configs.datasets.mc_ch_in_11kv2.rgb
ptbench.configs.datasets.mc_ch_in_11kv2_RS.default
ptbench.configs.datasets.mc_ch_in_pc.default
ptbench.configs.datasets.mc_ch_in_pc.rgb
ptbench.configs.datasets.mc_ch_in_pc_RS.default
ptbench.configs.datasets.montgomery.default
ptbench.configs.datasets.montgomery.rgb
ptbench.configs.datasets.montgomery_RS.default
ptbench.configs.datasets.nih_cxr14_re.cardiomegaly
ptbench.configs.datasets.nih_cxr14_re.default
ptbench.configs.datasets.nih_cxr14_re_pc.idiap
ptbench.configs.datasets.padchest.cardiomegaly_idiap
ptbench.configs.datasets.padchest.idiap
ptbench.configs.datasets.padchest.no_tb_idiap
ptbench.configs.datasets.padchest.tb_idiap
ptbench.configs.datasets.padchest.tb_idiap_rgb
ptbench.configs.datasets.padchest_RS.tb_idiap
ptbench.configs.datasets.shenzhen.default
ptbench.configs.datasets.shenzhen.rgb
ptbench.configs.datasets.shenzhen_RS.default
ptbench.configs.datasets.tbx11k_simplified.default
ptbench.configs.datasets.tbx11k_simplified.rgb
ptbench.configs.datasets.tbx11k_simplified_RS.default
ptbench.configs.datasets.tbx11k_simplified_v2.default
ptbench.configs.datasets.tbx11k_simplified_v2.rgb
ptbench.configs.datasets.tbx11k_simplified_v2_RS.default
.. _ptbench.configs.datasets.folds:
Cross-Validation Datasets
=========================
ptbench.data.indian.default
ptbench.data.montgomery.default
ptbench.data.nih_cxr14.default
ptbench.data.padchest.idiap
ptbench.data.shenzhen.default
ptbench.data.tbx11k.v1_healthy_vs_atb
ptbench.data.tbx11k.v2_others_vs_atb
.. _ptbench.configs.datamodules.remix:
Remix Datamodules
=================
We provide some aggregated datamodules to facilitate cross-database development.
.. autosummary::
:toctree: api/configs/datamodules
:template: config.rst
ptbench.data.montgomery_shenzhen.default
ptbench.data.montgomery_shenzhen_indian.default
ptbench.data.montgomery_shenzhen_indian_padchest.default
ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_healthy_vs_atb
ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_others_vs_atb
ptbench.data.nih_cxr14_padchest.idiap
.. _ptbench.configs.datamodules.folds:
Cross-validation Datamodules
============================
We support cross-validation with precise preset folds. In this section, you
will find the configuration for the first fold (fold-0) for all supported
datasets. Nine other folds are available for every configuration (from 1 to
9), making up 10 folds per supported dataset.
datamodules. Nine other folds are available for every configuration (from 1 to
9), making up 10 folds per supported datamodule.
.. autosummary::
:toctree: api/configs/datasets
:toctree: api/configs/datamodules
:template: config.rst
ptbench.configs.datasets.hivtb.fold_0
ptbench.configs.datasets.hivtb.fold_0_rgb
ptbench.configs.datasets.hivtb_RS.fold_0
ptbench.configs.datasets.indian.fold_0
ptbench.configs.datasets.indian.fold_0_rgb
ptbench.configs.datasets.indian_RS.fold_0
ptbench.configs.datasets.mc_ch.fold_0
ptbench.configs.datasets.mc_ch.fold_0_rgb
ptbench.configs.datasets.mc_ch_RS.fold_0
ptbench.configs.datasets.mc_ch_in.fold_0
ptbench.configs.datasets.mc_ch_in.fold_0_rgb
ptbench.configs.datasets.mc_ch_in_RS.fold_0
ptbench.configs.datasets.mc_ch_in_11k.fold_0
ptbench.configs.datasets.mc_ch_in_11k.fold_0_rgb
ptbench.configs.datasets.mc_ch_in_11k_RS.fold_0
ptbench.configs.datasets.mc_ch_in_11kv2.fold_0
ptbench.configs.datasets.mc_ch_in_11kv2.fold_0_rgb
ptbench.configs.datasets.mc_ch_in_11kv2_RS.fold_0
ptbench.configs.datasets.montgomery.fold_0
ptbench.configs.datasets.montgomery.fold_0_rgb
ptbench.configs.datasets.montgomery_RS.fold_0
ptbench.configs.datasets.shenzhen.fold_0
ptbench.configs.datasets.shenzhen.fold_0_rgb
ptbench.configs.datasets.shenzhen_RS.fold_0
ptbench.configs.datasets.tbpoc.fold_0
ptbench.configs.datasets.tbpoc.fold_0_rgb
ptbench.configs.datasets.tbpoc_RS.fold_0
ptbench.configs.datasets.tbx11k_simplified.fold_0
ptbench.configs.datasets.tbx11k_simplified.fold_0_rgb
ptbench.configs.datasets.tbx11k_simplified_RS.fold_0
ptbench.configs.datasets.tbx11k_simplified_v2.fold_0
ptbench.configs.datasets.tbx11k_simplified_v2.fold_0_rgb
ptbench.configs.datasets.tbx11k_simplified_v2_RS.fold_0
ptbench.data.hivtb.fold_0
ptbench.data.indian.fold_0
ptbench.data.montgomery.fold_0
ptbench.data.montgomery_shenzhen.fold_0
ptbench.data.montgomery_shenzhen_indian.fold_0
ptbench.data.montgomery_shenzhen_indian_tbx11k.v1_fold_0
ptbench.data.montgomery_shenzhen_indian_tbx11k.v2_fold_0
ptbench.data.shenzhen.fold_0
ptbench.data.tbpoc.fold_0
ptbench.data.tbx11k.v1_fold_0
ptbench.data.tbx11k.v2_fold_0
.. include:: links.rst
......@@ -92,10 +92,10 @@ Here is an example configuration file that may be useful as a starting point:
ptbench dataset check montgomery
.. _ptbench.setup.datasets:
.. _ptbench.setup.databases:
Supported Datasets
==================
Supported Databases
===================
Here is a list of currently supported datasets in this package, alongside
notable properties. Each dataset name is linked to the location where
......@@ -103,10 +103,10 @@ raw data can be downloaded. The list of images in each split is available
in the source code.
.. _ptbench.setup.datasets.tb:
.. _ptbench.setup.databases.tb:
Tuberculosis datasets
~~~~~~~~~~~~~~~~~~~~~
Tuberculosis databases
~~~~~~~~~~~~~~~~~~~~~~
The following datasets contain only the tuberculosis final diagnosis (0 or 1).
In addition to the splits presented in the following table, 10 folds
......@@ -146,8 +146,8 @@ In addition to the splits presented in the following table, 10 folds
.. _ptbench.setup.datasets.tb+signs:
Tuberculosis multilabel dataset
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tuberculosis multilabel databases
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following dataset contains the labels healthy, sick & non-TB, active TB,
and latent TB. The implemented tbx11k dataset in this package is based on
......
# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""CNN for detecting radiological findings.
A Densenet-121 model for radiological sign detection, using the NIH
CXR-14 label format (ie. 14 outputs).
"""
from torch.nn import BCEWithLogitsLoss
from torch.optim import Adam
from ...data.augmentations import ElasticDeformation
from ...models.densenet import Densenet
model = Densenet(
train_loss=BCEWithLogitsLoss(),
validation_loss=BCEWithLogitsLoss(),
optimizer_type=Adam,
optimizer_arguments=dict(lr=0.0001),
augmentation_transforms=[ElasticDeformation(p=0.8)],
pretrained=False,
num_classes=14, # number of classes in NIH CXR-14
)
# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""CNN for radiological findings detection.
A Densenet121 model for radiological extraction
"""
from torch import empty
from torch.nn import BCEWithLogitsLoss
from ...models.densenet_rs import DensenetRS
# Import the default protocol if none is available
if "dataset" not in locals():
from ..datasets.nih_cxr14_re import default
dataset = default.dataset
# config
optimizer_configs = {"lr": 1e-4}
# optimizer
optimizer = "Adam"
# criterion
criterion = BCEWithLogitsLoss(pos_weight=empty(1))
criterion_valid = BCEWithLogitsLoss(pos_weight=empty(1))
# model
model = DensenetRS(criterion, criterion_valid, optimizer, optimizer_configs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment