Skip to contents

The section's substance is the preprocessing contract, not the download: the image must be brought to the size the pretrained model expects (224 x 224 for ConvNeXt) and the pixel intensities standardized per colour channel using ImageNet's means and standard deviations. Those constants are NOT printed in the extracted text, so mean and sd are required arguments rather than baked-in defaults.

Usage

morie_pretprep(image, size, mean, sd, logits = NULL, topk = 1L)

Arguments

image

height by width by channels array

size

the square edge the model expects

mean, sd

per-channel standardization constants

logits

optional class logits, for the p. 459 argmax read-out

topk

how many classes to report

Value

list(pixels, size, channels, cropside, pixelmean, pixelmax, and pred/topk/topprob when logits are supplied)

Details

ponytail: centre crop to a square, then nearest-neighbour subsample. weights.transforms() uses bilinear resizing; swap the sampler if you need to match torchvision to the last decimal.

Examples

set.seed(1)
img <- array(runif(8 * 8 * 3), dim = c(8, 8, 3))
out <- morie_pretprep(img, size = 4, mean = c(0.5, 0.5, 0.5),
                      sd = c(0.25, 0.25, 0.25))
dim(out$image)
#> NULL