use of deepboof.io.torch7.ParseAsciiTorch7 in project BoofCV by lessthanoptimal.
the class ImageClassifierNiNImageNet method loadModel.
@Override
public void loadModel(File directory) throws IOException {
List<TorchObject> list = new ParseBinaryTorch7().parse(new File(directory, "nin_bn_final.t7"));
TorchGeneric torchSequence = ((TorchGeneric) list.get(0)).get("model");
TorchGeneric torchNorm = torchSequence.get("transform");
mean = torchListToArray((TorchList) torchNorm.get("mean"));
stdev = torchListToArray((TorchList) torchNorm.get("std"));
SequenceAndParameters<Tensor_F32, Function<Tensor_F32>> seqparam = ConvertTorchToBoofForward.convert(torchSequence);
network = seqparam.createForward(3, imageCrop, imageCrop);
tensorOutput = new Tensor_F32(WI(1, network.getOutputShape()));
TorchList torchCategories = (TorchList) new ParseAsciiTorch7().parse(new File(directory, "synset.t7")).get(0);
categories.clear();
for (int i = 0; i < torchCategories.list.size(); i++) {
categories.add(((TorchString) torchCategories.list.get(i)).message);
}
}
Aggregations