ImageClassificationTask
Task for classifying images into discrete categories.
Image classification predicts categorical labels from image inputs. It accepts image columns as inputs, requires a single categorical output column, and is compatible with image classifier models.
Methods
prepare_for_task(self, dataset: Union[ForwardRef('DatasetDict'), ForwardRef('DashAIDataset')], input_columns: List[str], output_columns: List[str]) -> 'DashAIDataset'
ImageClassificationTaskPrepare a dataset for an image classification task.
Parameters
- dataset : Union[DatasetDict, DashAIDataset]
- Dataset to be prepared.
- input_columns : List[str]
- Names of the image input columns.
- output_columns : List[str]
- Names of the categorical output columns.
Returns
- DashAIDataset
- The validated dataset, ready for training or inference.
check_role_names(self, roles: Mapping[str, Any]) -> None
BaseTaskRefuse columns for a role this task does not declare.
column_roles(cls) -> Tuple[DashAI.back.tasks.column_roles.ColumnRole, ...]
BaseTaskThe roles this task's columns can play, in the order it declares.
Returns
- tuple of ColumnRole
- The declared roles.
get_metadata(cls) -> Dict[str, Any]
BaseTaskReturn serialisable metadata for the current task.
Parameters
- cls : type
- The task class (injected automatically by Python for classmethods).
Returns
- Dict[str, Any]
- Dictionary with keys
"inputs_types","outputs_types","inputs_cardinality","outputs_cardinality","column_roles","io_roles"and"requires_target".
io_columns(self, roles: Mapping[str, Sequence]) -> DashAI.back.tasks.column_roles.IOColumns
BaseTaskTranslate a session's roles into a model's inputs and outputs.
Parameters
- roles : mapping
- Role name to the role's columns, as names or as column refs.
Returns
- IOColumns
- The entries that feed the model as
xand asy.
io_roles(cls) -> Dict[str, List[str]]
BaseTaskWhich roles feed a model's inputs and which its outputs.
Returns
- dict
{"inputs": [role names], "outputs": [role names]}.
num_labels(self, dataset: 'DashAIDataset', output_column: str) -> int | None
ClassificationTaskGet the number of unique labels in the output column.
Parameters
- dataset : DashAIDataset
- Dataset used for training
- output_column : str
- Output column
Returns
- int | None
- Number of unique labels or None if not applicable
process_manual_input(self, manual_input: List[dict], dataset_path: str) -> 'DashAIDataset'
BaseTaskProcess manual input data into a DashAIDataset with type validation.
Parameters
- manual_input : List[dict]
- List of dictionaries representing manual input data.
- dataset_path : str
- Path to the training dataset (used to get column specs for validation)
Returns
- DashAIDataset
- Processed DashAIDataset from manual input.
process_predictions(self, dataset: 'DashAIDataset', predictions: 'ndarray', output_column: str) -> 'ndarray'
ClassificationTaskProcess the predictions to return the class labels.
Parameters
- dataset : DashAIDataset
- Dataset used for training
- predictions : np.ndarray
- Predictions from the model (probabilities for each class)
- output_column : str
- Output column
Returns
- np.ndarray
- Processed predictions with class labels
roles_from_io(self, input_columns: Sequence, output_columns: Sequence) -> Dict[str, list]
BaseTaskTranslate a model's inputs and outputs back into roles.
Parameters
- input_columns, output_columns : sequence
- The columns fed to the model as
xand asy.
Returns
- dict
- Role name to the role's columns.
validate_dataset_for_task(self, dataset: 'DashAIDataset', dataset_name: str, input_columns: List[str], output_columns: Optional[List[str]]) -> None
BaseTaskValidate a dataset for the current task.
Parameters
- dataset : DashAIDataset
- Dataset to be validated
- dataset_name : str
- Dataset name
- input_columns : list of str
- Names of the columns selected as inputs.
- output_columns : list of str
- Names of the columns selected as outputs.
validate_estimated_role(self, role_name: str, columns: Sequence[Tuple[Optional[str], Optional[int]]]) -> None
BaseTaskCheck one role against the columns a preprocessing chain will give it.
Parameters
- role_name : str
- A declared role.
- columns : sequence of (type name, count)
- One entry per estimated output: the name of its type, or None when unknown, and how many columns it holds, or None when unknown. An unknown count is taken as at least one, and only the role's minimum is checked then.
validate_role(self, role_name: str, columns: Sequence[str], types: Mapping[str, Any]) -> None
BaseTaskCheck one role's columns against its types and cardinality.
Parameters
- role_name : str
- A declared role.
- columns : sequence of str
- The names of the role's columns.
- types : mapping
- The dataset's column types, keyed by column name.
validate_roles(self, roles: Mapping[str, Sequence[str]], types: Mapping[str, Any]) -> None
BaseTaskCheck a session's columns, role by role, against the declaration.
Parameters
- roles : mapping
- Role name to the names of the role's columns.
- types : mapping
- The dataset's column types, keyed by column name.