use of deepboof.io.torch7.ParseBinaryTorch7 in project BoofCV by lessthanoptimal.
the class ImageClassifierResNet method loadModel.
@Override
public void loadModel(File path) throws IOException {
String name = String.format("resnet/resnet-%d.t7", resnetID);
List<TorchObject> list = new ParseBinaryTorch7().parse(new File(path, name));
TorchGeneric torchSequence = (TorchGeneric) list.get(0);
// mean = torchListToArray( (TorchList)torchNorm.get("mean"));
// stdev = torchListToArray( (TorchList)torchNorm.get("std"));
SequenceAndParameters<Tensor_F32, Function<Tensor_F32>> seqparam = ConvertTorchToBoofForward.convert(torchSequence);
System.out.println("Bread here");
}
use of deepboof.io.torch7.ParseBinaryTorch7 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);
}
}
use of deepboof.io.torch7.ParseBinaryTorch7 in project BoofCV by lessthanoptimal.
the class ImageClassifierVggCifar10 method loadModel.
/**
* Expects there to be two files in the provided directory:<br>
* YuvStatistics.txt<br>
* model.net<br>
*
* @param directory Directory containing model files
* @throws IOException Throw if anything goes wrong while reading data
*/
@Override
public void loadModel(File directory) throws IOException {
stats = DeepModelIO.load(new File(directory, "YuvStatistics.txt"));
SequenceAndParameters<Tensor_F32, Function<Tensor_F32>> sequence = new ParseBinaryTorch7().parseIntoBoof(new File(directory, "model.net"));
network = sequence.createForward(3, inputSize, inputSize);
tensorOutput = new Tensor_F32(WI(1, network.getOutputShape()));
BorderType type = BorderType.valueOf(stats.border);
localNorm = new ImageLocalNormalization<>(GrayF32.class, type);
kernel = DataManipulationOps.create1D_F32(stats.kernel);
}
Aggregations