Skip to main content

EfficientNetB0ImageClassifier

Model
DashAI.back.models.EfficientNetB0ImageClassifier

EfficientNet-B0 image classifier (Tan & Le, 2019).

Compact baseline of the EfficientNet family, which scales network width, depth, and resolution jointly. The classifier head is replaced to match the number of target classes. Supports ImageNet pre-trained weights.

Parameters

epochs : integer, default=10
The number of epochs to train the model. An epoch is a full iteration over the training data.
learning_rate : number, default=0.001
Learning rate for the Adam optimizer.
batch_size : integer, default=32
Number of images processed together in each training step. Larger values speed up training but require more memory.
image_size : integer, default=224
Images are resized to this value (in pixels) for both width and height. Use 224 for ImageNet-pretrained models.
dropout_rate : number, default=0.0
Dropout rate applied before the output layer. Values between 0.2 and 0.5 help prevent overfitting.
weight_decay : number, default=0.0
L2 regularization coefficient for the Adam optimizer. Typical values: 1e-4 to 1e-2.
pretrained : boolean, default=True
If True, loads weights pre-trained on ImageNet. Recommended when your dataset is small or similar to natural images.
freeze_backbone : boolean, default=False
If True, freezes the convolutional backbone and only trains the classifier head. Useful for very small datasets.
device : string, default=CPU
Hardware device used for training and inference (CPU/GPU).

Methods

calculate_metrics(self, split: DashAI.back.core.enums.metrics.SplitEnum = <SplitEnum.VALIDATION: 'validation'>, level: DashAI.back.core.enums.metrics.LevelEnum = <LevelEnum.LAST: 'last'>, log_index: int = None, x_data: 'DashAIDataset' = None, y_data: 'DashAIDataset' = None)

Defined on BaseModel

Calculate and save metrics for a given data split and level.

Parameters

split : SplitEnum
The data split to evaluate (TRAIN, VALIDATION, or TEST). Defaults to SplitEnum.VALIDATION.
level : LevelEnum
The metric granularity level (LAST, TRIAL, STEP, or BATCH). Defaults to LevelEnum.LAST.
log_index : int, optional
Explicit step index for the metric entry. If None, the next step index is computed automatically. Defaults to None.
x_data : DashAIDataset, optional
Input features. If None, the dataset stored in the model for the given split is used. Defaults to None.
y_data : DashAIDataset, optional
Target labels. If None, the labels stored in the model for the given split are used. Defaults to None.

get_metadata(cls) -> Dict[str, Any]

Defined on BaseModel

Get metadata values for the current model.

Returns

Dict[str, Any]
Dictionary containing UI metadata such as the model icon used in the DashAI frontend.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

load(cls, filename: 'str')

Defined on TorchvisionImageClassifier

Load a model checkpoint from disk.

Parameters

filename : str
Path to the checkpoint file.

Returns

BaseTorchvisionImageClassifier
Instance with loaded weights.

predict(self, x)

Defined on TorchvisionImageClassifier

Return per-class probability matrix for each image.

Parameters

x : DashAIDataset
Input dataset containing images.

Returns

np.ndarray
Array of shape (n_samples, n_classes) with softmax probabilities.

prepare_dataset(self, dataset: 'DashAIDataset', is_fit: bool = False) -> 'DashAIDataset'

Defined on BaseModel

Hook for model-specific preprocessing of input features.

Parameters

dataset : DashAIDataset
The input dataset to preprocess.
is_fit : bool
Whether the call is part of a fitting phase. Defaults to False.

Returns

DashAIDataset
The preprocessed dataset ready to be fed into the model.

prepare_output(self, dataset, is_fit=False)

Defined on TorchvisionImageClassifier

Encode string labels to integer indices matching the model's class order.

save(self, filename: 'str') -> 'None'

Defined on TorchvisionImageClassifier

Save the model checkpoint to disk.

Parameters

filename : str
Path where the checkpoint will be saved.

train(self, x_train, y_train, x_validation=None, y_validation=None)

Defined on TorchvisionImageClassifier

Fine-tune the backbone on the provided image dataset.

Parameters

x_train : DashAIDataset
Input dataset containing images.
y_train : DashAIDataset
Target dataset containing string labels.
x_validation : DashAIDataset, optional
Validation input features. Defaults to None.
y_validation : DashAIDataset, optional
Validation target labels. Defaults to None.

Returns

BaseTorchvisionImageClassifier
The trained model instance.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.

Compatible with