Skip to content

Using CAREamics

The CAREamist API is the recommended way to use CAREamics, it is a two stage process, in which users first define a configuration and then use a the CAREamist to run their training and prediction.

More advanced users wishing to have more control over the training and prediction process can re-use CAREamics module in a Pytorch Lightning script, which we refer to as the Lightning API.

Quick start

from careamics.careamist import CAREamist
from careamics.config.factories import create_n2v_config

# create a configuration
config = create_n2v_config(
    experiment_name="n2v_training",
    data_type="array",  # (1)!
    axes="YX",
    patch_size=[64, 64],
    batch_size=8,
    num_epochs=30,
)

# instantiate a careamist
careamist = CAREamist(config)

# train the model
careamist.train(train_data=train_data)  # (2)!

# once trained, predict
prediction = careamist.predict(pred_data=pred_data)
  1. This is training from arrays in memory, but this can also be done with files on disk.

  2. The only important thing is that the data passed is coherent with the choice in the configuration.

from careamics.careamist import CAREamist
from careamics.config.factories import create_care_config

# create a configuration
config = create_care_config(
    experiment_name="care_2D",
    data_type="array",  # (1)!
    axes="YX",
    patch_size=[64, 64],
    batch_size=8,
    num_epochs=30,
)

# instantiate a careamist
careamist = CAREamist(config)

# train the model
careamist.train(
    train_data=train_data,  # (2)!
    train_data_target=train_target,
    val_data=val_data,
    val_data_target=val_target,
)

# once trained, predict
prediction = careamist.predict(pred_data=pred_data)
  1. This is training from arrays in memory, but this can also be done with files on disk.

  2. The only important thing is that the data passed is coherent with the choice in the configuration.

Explore CAREamics