Tasks#

aitlas.tasks.evaluate module#

class EvaluateTask(model, config)[source]#

Bases: BaseTask

Parameters:

model (BaseModel) –

schema#

alias of EvaluateTaskSchema

run()[source]#

Evaluate the dataset against a given model

aitlas.tasks.extract_features module#

class ExtractFeaturesTask(model, config)[source]#

Bases: BaseTask

Parameters:

model (BaseModel) –

schema#

alias of ExtractFeaturesTaskSchema

run()[source]#

Do something awesome here

aitlas.tasks.predict module#

class ImageFolderDataset(data_dir, labels, transforms, batch_size)[source]#

Bases: BaseDataset

class PredictTask(model, config)[source]#

Bases: BaseTask

Parameters:

model (BaseModel) –

schema#

alias of PredictTaskSchema

run()[source]#

Do something awesome here

export_predictions_to_csv(file, fnames, probs, labels)[source]#
class PredictSegmentationTask(model, config)[source]#

Bases: BaseTask

Parameters:

model (BaseModel) –

schema#

alias of PredictTaskSchema

run()[source]#

Do something awesome here

class PredictEOPatchTask(model, config)[source]#

Bases: BaseTask

Parameters:

model (BaseModel) –

schema#

alias of PredictTaskSchema

run()[source]#

Do something awesome here

export_predictions_to_csv(file, fnames, probs, labels)[source]#

aitlas.tasks.prepare module#

class PrepareTask(model, config)[source]#

Bases: BaseTask

If the prepare part (or a version of it) is extensive, you can run it as a separate task

Parameters:

model (BaseModel) –

schema#

alias of PrepareTaskSchema

run()[source]#

Do some offline preparation

aitlas.tasks.schemas module#

class BaseTaskShema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: Schema

Schema for configuring a base task.

Parameters:
  • log (bool, optional) – Flag indicating whether to turn on logging. Default is True.

  • id (str, optional) – Run name/ID for the task. Default is None.

  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
class SplitSetObjectSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: Schema

Schema for configuring a split dataset object.

Parameters:
  • ratio (int) – Ratio of the dataset to include in the split. This is required.

  • file (str) – File containing the indices for the split. This is required.

  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
class SplitObjectSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: Schema

Parameters:
  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
class SplitTaskSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: BaseTaskShema

Schema for configuring a split task.

Parameters:
  • data_dir (str) – Path to the dataset on disk. This is required.

  • csv_file (str, optional) – CSV file on disk containing dataset information. Default is None.

  • split (SplitObjectSchema, optional) – Configuration on how to split the dataset. Default is None.

  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
fields: Dict[str, ma_fields.Field]#

Dictionary mapping field_names -> Field objects

load_fields: Dict[str, ma_fields.Field]#
dump_fields: Dict[str, ma_fields.Field]#
class TrainTaskSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: BaseTaskShema

Schema for configuring a training task.

Parameters:
  • dataset_config (ObjectConfig) – Train dataset type and configuration. This is required.

  • epochs (int) – Number of epochs used in training. This is required.

  • model_directory (str) – Directory of the model output. This is required.

  • save_epochs (int, optional) – Number of training steps between model checkpoints. Default is 100.

  • iterations_log (int, optional) – After how many mini-batches do we want to show something in the log. Default is 200.

  • resume_model (str, optional) – File path to the model to be resumed. Default is None.

  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
fields: Dict[str, ma_fields.Field]#

Dictionary mapping field_names -> Field objects

load_fields: Dict[str, ma_fields.Field]#
dump_fields: Dict[str, ma_fields.Field]#
class TrainAndEvaluateTaskSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: BaseTaskShema

Schema for configuring a task that involves training and evaluation.

Parameters:
  • epochs (int) – Number of epochs used in training. This is required.

  • model_directory (str) – Directory of the model output. This is required.

  • save_epochs (int, optional) – Number of training steps between model checkpoints. Default is 100.

  • iterations_log (int, optional) – After how many mini-batches do we want to show something in the log. Default is 200.

  • resume_model (str, optional) – File path to the model to be resumed. Default is None.

  • train_dataset_config (ObjectConfig) – Train dataset type and configuration. This is required.

  • val_dataset_config (ObjectConfig) – Validation dataset type and configuration. This is required.

  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
fields: Dict[str, ma_fields.Field]#

Dictionary mapping field_names -> Field objects

load_fields: Dict[str, ma_fields.Field]#
dump_fields: Dict[str, ma_fields.Field]#
class ParameterSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: Schema

Parameters:
  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
class OptimizeTaskSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: BaseTaskShema

Schema for configuring an optimization task.

Parameters:
  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
fields: Dict[str, ma_fields.Field]#

Dictionary mapping field_names -> Field objects

load_fields: Dict[str, ma_fields.Field]#
dump_fields: Dict[str, ma_fields.Field]#
class EvaluateTaskSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: BaseTaskShema

Schema for configuring an evaluation task.

Parameters:
  • dataset_config (ObjectConfig) – Dataset type and configuration. This is required.

  • model_path (str) – Path to the model. This is required.

  • metrics (List[str], optional) – Metric classes you want to calculate. Default is an empty list.

  • visualizations (List[str], optional) – Visualization classes you want to show. Default is an empty list.

  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
fields: Dict[str, ma_fields.Field]#

Dictionary mapping field_names -> Field objects

load_fields: Dict[str, ma_fields.Field]#
dump_fields: Dict[str, ma_fields.Field]#
class PredictTaskSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: BaseTaskShema

Schema for configuring a prediction task.

Parameters:
  • data_dir (str) – Directory with the image to perform prediction on. This is required.

  • model_path (str) – Path to the model. This is required.

  • output_dir (str, optional) – Folder path where the plot images with predictions will be stored. Default is ‘/predictions’.

  • output_file (str, optional) – CSV file path where the predictions will be stored. Default is ‘predictions.csv’.

  • dataset_config (ObjectConfig, optional) – Dataset type and configuration. Default is None.

  • batch_size (int, optional) – Batch size. Default is 64.

  • labels (List[str], optional) – Labels needed to tag the predictions. Default is None.

  • transforms (List[str], optional) – Classes to run transformations. Default is a list of common torchvision transformations.

  • output_format (str, optional) – Whether to output the predictions to CSV or plots. Default is ‘plot’. Must be one of [‘plot’, ‘csv’, ‘image’].

  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
fields: Dict[str, ma_fields.Field]#

Dictionary mapping field_names -> Field objects

load_fields: Dict[str, ma_fields.Field]#
dump_fields: Dict[str, ma_fields.Field]#
class PrepareTaskSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: BaseTaskShema

Parameters:
  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
fields: Dict[str, ma_fields.Field]#

Dictionary mapping field_names -> Field objects

load_fields: Dict[str, ma_fields.Field]#
dump_fields: Dict[str, ma_fields.Field]#
class ExtractFeaturesTaskSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: BaseTaskShema

Schema for configuring a task to extract features from images.

Parameters:
  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
fields: Dict[str, ma_fields.Field]#

Dictionary mapping field_names -> Field objects

load_fields: Dict[str, ma_fields.Field]#
dump_fields: Dict[str, ma_fields.Field]#
class VisualizeSplitSetObjectSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: Schema

Parameters:
  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
class VisualizeSplitObjectSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: Schema

Parameters:
  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
class VisualizeTaskSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]#

Bases: BaseTaskShema

Parameters:
  • only (types.StrSequenceOrSet | None) –

  • exclude (types.StrSequenceOrSet) –

  • many (bool) –

  • context (dict | None) –

  • load_only (types.StrSequenceOrSet) –

  • dump_only (types.StrSequenceOrSet) –

  • partial (bool | types.StrSequenceOrSet) –

  • unknown (str | None) –

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>#
fields: Dict[str, ma_fields.Field]#

Dictionary mapping field_names -> Field objects

load_fields: Dict[str, ma_fields.Field]#
dump_fields: Dict[str, ma_fields.Field]#

aitlas.tasks.split module#

class BaseSplitTask(model, config)[source]#

Bases: BaseTask

Base task meant to split dataset

Parameters:

model (BaseModel) –

schema#

alias of SplitTaskSchema

is_multilabel = False#
extensions = ['.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tiff', '.webp']#
run()[source]#
has_val()[source]#
is_split_valid()[source]#
split()[source]#
save_split(X, y, file)[source]#
load_images(data_dir, csv_file, extensions=None)[source]#

Attempts to read in VOC format, then in internal format, then in folder per class format

make_splits()[source]#
perform_split(X, y, test_size)[source]#
class RandomSplitTask(model, config)[source]#

Bases: BaseSplitTask

Randomly split a folder containing images

Parameters:

model (BaseModel) –

perform_split(X, y, test_size)[source]#

Peform actual split using pytorch random split

class StratifiedSplitTask(model, config)[source]#

Bases: BaseSplitTask

Meant for multilabel stratified slit

Parameters:

model (BaseModel) –

perform_split(X, y, test_size)[source]#

Perform the actual split using sklearn or skmultilearn

aitlas.tasks.train module#

class TrainTask(model, config)[source]#

Bases: BaseTask

Parameters:

model (BaseModel) –

schema#

alias of TrainTaskSchema

run()[source]#

Do something awesome here

class TrainAndEvaluateTask(model, config)[source]#

Bases: BaseTask

Parameters:

model (BaseModel) –

schema#

alias of TrainAndEvaluateTaskSchema

run()[source]#

Do something awesome here

generate_parameters_for_range(method, parameter)[source]#
generate_parameters(method, parameters)[source]#

Generate parameters to search

class OptimizeTask(model, config)[source]#

Bases: BaseTask

Optimize certain parameters for the models

Parameters:

model (BaseModel) –

schema#

alias of OptimizeTaskSchema

run()[source]#

Do something awesome here

aitlas.tasks.unsupervised_pre_training module#

Note

Not implemented yet in the stable version

aitlas.tasks.visualize module#

class VisualizeTask(model, config)[source]#

Bases: BaseTask

Parameters:

model (BaseModel) –

schema#

alias of VisualizeTaskSchema

get_distribution_for_split(split, split_type)[source]#
get_distribution()[source]#
run()[source]#

Visualize the distribution of the dataset