@@ -53,29 +53,32 @@ proc run(model: shared VGG16(real(32)), file: string) {
5353 return (topPredictions.data, percentTopk);
5454}
5555
56+ import Path;
57+
58+
5659proc main(args: [] string ) {
57- writeln (" Loading labels from " , labelFile);
58- const labels = getLabels();
59- writeln (" Loaded " , labels.size, " labels." );
60+ writeln (" Loading labels from " , labelFile);
61+ const labels = getLabels();
62+ writeln (" Loaded " , labels.size, " labels." );
6063
61- writeln (" Constructing VGG16 model." );
62- const vgg = new shared VGG16(real (32 ));
63- writeln (" Constructed VGG16 model." );
64+ writeln (" Constructing VGG16 model." );
65+ const vgg = new shared VGG16(real (32 ));
66+ writeln (" Constructed VGG16 model." );
6467
65- writeln (" Loading VGG16 model weights." );
66- vgg.loadPyTorchDump(modelDir, false );
67- writeln (" Loaded VGG16 model." );
68+ writeln (" Loading VGG16 model weights." );
69+ vgg.loadPyTorchDump(modelDir, false );
70+ writeln (" Loaded VGG16 model." );
6871
6972
70- var files = args[ 1 ..] ;
73+ var files = args[ 1 ..] ;
7174
72- for f in files {
73- var (topArr, percent) = run(vgg, f);
74- writeln (" For '" , f, " ' the top " , k, " predictions are: " );
75- for i in 0 ..< k {
76- writef(" %?: label=%?; confidence=%2.2r%% \n " , i, labels[ topArr[ i]] , percent[ i] );
75+ for f in files {
76+ var (topArr, percent) = run(vgg, f);
77+ writeln (" For '" , f, " ' the top " , k, " predictions are: " );
78+ for i in 0 ..< k {
79+ writef(" %?: label=%?; confidence=%2.2r%% \n " , i, labels[ topArr[ i]] , percent[ i] );
80+ }
81+ writeln ();
7782 }
78- writeln ();
79- }
8083
8184}
0 commit comments