mml.core.data_loading.task_struct
- class TaskStruct[source]
Bases:
objectObject to handle tasks on a meta level in the framework. Contains basic information on location of data and links to intermediate and final results. Will be instantiated by the TaskFactory. During runtime results corresponding to the dataset will also be stored within the object (such as trained models, calculated FIM and performance).
- __init__(name: str, task_type: TaskType, means: RGBInfo, stds: RGBInfo, sizes: Sizes, class_occ: Dict[str, int], keywords: List[Keyword], idx_to_class: Dict[int, str], modalities: Dict[Modality, str], relative_root: str, preprocessed: str)[source]
- property id: str
Deprecated since version 0.12.0: task_struct.id is deprecated, use task.name instead
- static non_permanent_task_attributes() Dict[str, Tuple[Callable, Callable]][source]
Returns a dict of task attributes that are not part of the task meta information but are computed by MML. The value within the dict is a tuple of callables representing and instantiating the object (to be compatible with yaml safe loading and dumping).
- Returns:
dict with str keys, which are the names of task struct attributes that might be set during MML runtime and tuple vals corresponding to (representer, instantiator)
- class TaskStructFactory[source]
Bases:
objectManages to load all necessary TaskStructs for an experiment. Stores created objects and aggregates information (like sizes) across multiple tasks.
- create_task_struct(name: str, return_ref=False) None | TaskStruct[source]
Creates a task struct object via loading necessary information from the meta info json file and adding reusable information (e.g. intermediate results from previous experiments) as adaption of the already preprocessed version of the task. Finally, the task struct is added to the internal container.
- Parameters:
name – name of the task to be created
return_ref – if true returns a reference to the created struct, else returns None
- Returns:
either the created task struct or None
- dump(clear_container=False) None[source]
Stores current tasks and their attributes.
- Parameters:
clear_container – if true deletes currently loaded tasks afterwards
- Returns:
None
- get_by_name(name: str) TaskStruct[source]
Returns the internally stored task_struct corresponding to >name<. Raises an error if not found (or returns only false if >test< is true).
- Parameters:
name – task name
test – if true does not raise an error
- Returns:
either the task_struct or False if not found and in test mode
- loading_old_dump() None[source]
Loading is useful if an experiment was aborted and is re-initialized.
- Returns:
None
- set_task_struct_defaults(task_struct: TaskStruct)[source]
Based on reuse configs this sets the defaults within the task struct regarding previous results. Currently only supports Path and ModelStorage objects!
- Parameters:
task_struct (TaskStruct) – task_struct of the task that values should be loaded
- Returns:
None
- undup_names(moded_names_list)[source]
This function removes the “duplicate”-suffixes of tasks that is added if some tasks are present for multiple times.
- Parameters:
moded_names_list – list of strings, task names potentially including the “duplicate”-suffix
- Returns:
list of strings, tasks names without the suffix (if suffix is not present the name stays equal)