EfficientNetB0
The EfficientNet originates from the "EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks" paper, which proposes a new compound scaling method that enables better performance on image classification tasks with fewer parameters. EfficientNet B0 is the smallest and most efficient model in the EfficientNet family, achieving state-of-the-art results on various image classification benchmarks with just 5.3 million parameters.
Overall
- Framework: PyTorch
- Model format: ONNX
- Model task: Image classification
- Source: github
Usages
from furiosa.models.vision import EfficientNetB0
from furiosa.runtime.sync import create_runner
image = "tests/assets/cat.jpg"
effnetb0 = EfficientNetB0()
with create_runner(effnetb0.model_source()) as runner:
inputs, _ = effnetb0.preprocess(image)
outputs = runner.run(inputs)
effnetb0.postprocess(outputs)
Inputs
The input is a 3-channel image of 224x224 (height, width).
- Data Type:
numpy.float32
- Tensor Shape:
[1, 3, 224, 224]
- Memory Format: NCHW, where:
- N - batch size
- C - number of channels
- H - image height
- W - image width
- Color Order: BGR
- Optimal Batch Size (minimum: 1): <= 16
Outputs
The output is a numpy.float32
tensor with the shape ([1,]
), including
a class id. postprocess()
transforms the class id to a label string.
Pre/Postprocessing
furiosa.models.vision.EfficientNetB0
class provides preprocess
and postprocess
methods that
convert input images to input tensors and the model outputs to labels respectively.
You can find examples at EfficientNetB0 Usage.
furiosa.models.vision.EfficientNetB0.preprocess
Read and preprocess an image located at image_path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Union[str, Path, ArrayLike]
|
A path of an image. |
required |
with_scaling |
bool
|
Whether to apply model-specific techniques that involve scaling the model's input and converting its data type to float32. Refer to the code to gain a precise understanding of the techniques used. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, None]
|
The first element of the tuple is a numpy array that meets the input requirements of the model. The second element of the tuple is unused in this model and has no value. To learn more information about the output numpy array, please refer to Inputs. |
furiosa.models.vision.EfficientNetB0.postprocess
Convert the outputs of a model to a label string, such as car and cat.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_outputs |
Sequence[numpy.ArrayLike]
|
the outputs of the model. Please learn more about the output of model, please refer to Outputs. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A classified label, e.g., "jigsaw puzzle". |
Notes on the source field of this model
There is a significant update in sdk version 0.9.0, which involves that the Furiosa's quantization tool adopts DFG(Data Flow Graph) as its output format instead of onnx. DFG is an IR of FuriosaAI that supports more diverse quantization schemes than onnx and is more specialized for FuriosaAI’s Warboy.
The EfficientNetB0 we offer has been quantized with furiosa-sdk 0.9.0 and thus formatted in DFG. The ONNX file in the source field is the original f32 model, not yet quantized.
In case you need to use a different batch size or start from scratch, you can either start from the DFG or use the original ONNX file (and repeat the quantization process).