FFCV Inference Using fastai

fastai DataBlock items for use with Loader trained models

FFCV is currently hardcoded to use OpenCV’s INTER_AREA when resizing images, while fastai uses Pillow.

This module provides OpenCV versions of fastai DataBlock items, prefixed with FFAI, for inference after training with Loader.

FFAI Image Loading

FFAIBase is the OpenCV version of fastai.vision.core.PILBase. It uses OpenCV for image loading and type dispatch transforms.

Unlike OpenCV, these images load in RGB format.


source

FFAIBase

 FFAIBase (input_array)

Base class for a FFCV image that can show itself and convert to a Tensor


source

FFAIImage

 FFAIImage (input_array)

A RGB FFCV image that can show itself and converts to TensorImage

Unlike OpenCV images, FFCV images and FFAIImage are in RGB format.


source

FFAIImageBW

 FFAIImageBW (input_array)

A BW FFCV image that can show itself and converts to TensorImageBW


source

FFAIMask

 FFAIMask (input_array)

A FFCV image mask that can show itself and converts to TensorMask


source

encodes

 encodes (o:__main__.FFAIMask)

source

encodes

 encodes (o:__main__.FFAIMask)

Any data augmentation transform that runs on FFAI Images must be run before the fastai.data.transform.ToTensor transform, which has an order of 5.

FFAI ImageBlocks

FFAIImageBlock is identical to fastai.vision.data.ImageBlock except it uses FFAIImage by default.


source

FFAIImageBlock

 FFAIImageBlock (cls:__main__.FFAIBase=<class '__main__.FFAIImage'>)

A TransformBlock for images of cls

Basic FFAI Item Transforms

Currently only FFAICenterCrop is implemented for inference.


source

FFAICenterCrop

 FFAICenterCrop (output_size:int, ratio:float, interpolation=(3, 0))

A transform with a __repr__ that shows its attrs

Type Default Details
output_size int Square size to resize and crop image to
ratio float Ratio of (crop size) / (min side length)
interpolation tuple (3, 0) OpenCV interpolation mode, resamples[1] for mask