You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2023. It is now read-only.
I noticed that the preprocessing and the deprocessing only worked for the VGG model, and it also seems true for Apple's coremltools. In the original fast-neural-style code , the ResNet preprocess is done as
function M.resnet.preprocess(img)
check_input(img)
local mean = img.new(resnet_mean):view(1, 3, 1, 1):expandAs(img)
local std = img.new(resnet_std):view(1, 3, 1, 1):expandAs(img)
return (img - mean):cdiv(std)
end
while for VGG is done through
function M.vgg.preprocess(img)
check_input(img)
local mean = img.new(vgg_mean):view(1, 3, 1, 1):expandAs(img)
local perm = torch.LongTensor{3, 2, 1}
return img:index(2, perm):mul(255):add(-1, mean)
end
The difference is that for the ResNet model the image is in the range [0, 1] while for the VGG it is in the range [0, 255].
In your example, to use coremltools' API you defined the preprocessing and deprocessing as