Skip to content
Snippets Groups Projects
Commit 95c29672 authored by Shane's avatar Shane
Browse files

Add inference VGG16

parent ede8c23f
No related branches found
No related tags found
No related merge requests found
No preview for this file type
[[ 0.0004, 0.0533, 0.0103, 0.0003, 0.0005, 0.0027, 0.0158, 0.0203, 0.0019, 0.0138, 0.0175, 0.0009, 0.0010, 0.0080, 0.0141, 0.0190, 0.0065, 0.0106, 0.0028, 0.0005, 0.0002, 0.0003, 0.0004, 0.0006, 0.0076, 0.0002, 0.0024, 0.0031, 0.0002, 0.0103, 0.0004, 0.0091, 0.0002, 0.0005, 0.0007, 0.0004, 0.0011, 0.0015, 0.0006, 0.0249, 0.0007, 0.0008, 0.0051, 0.0016, 0.0086, 0.0126, 0.0008, 0.0158, 0.0356, 0.0012, 0.0003, 0.0002, 0.0140, 0.0070, 0.0173, 0.0161, 0.0136, 0.0052, 0.0106, 0.0007, 0.0011, 0.0149, 0.0010, 0.0018, 0.0111, 0.0140, 0.0009, 0.0036, 0.0021, 0.0029, 0.0176, 0.0015, 0.0615, 0.0002, 0.0095, 0.0001, 0.0276, 0.0058, 0.0019, 0.0114, 0.0057, 0.0016, 0.0002, 0.0006, 0.0090, 0.0061, 0.0094, 0.0011, 0.0124, 0.0064, 0.0014, 0.0152, 0.0018, 0.0147, 0.0079, 0.0058, 0.0012, 0.0217, 0.0075, 0.0019, 0.0081, 0.0138, 0.0024, 0.0008, 0.0193, 0.0003, 0.0028, 0.0111, 0.0051, 0.0066, 0.0098, 0.0002, 0.0001, 0.0148, 0.0113, 0.0225, 0.0035, 0.0088, 0.0143, 0.0010, 0.0004, 0.0133, 0.0021, 0.0015, 0.0015, 0.0003, 0.0084, 0.0109, 0.0100, 0.0102, 0.0143, 0.0118, 0.0045]]
\ No newline at end of file
[[ 0.0002, 0.0577, 0.0171, 0.0003, 0.0003, 0.0012, 0.0196, 0.0159, 0.0025, 0.0135, 0.0165, 0.0007, 0.0012, 0.0087, 0.0152, 0.0210, 0.0070, 0.0108, 0.0023, 0.0005, 0.0001, 0.0003, 0.0002, 0.0004, 0.0074, 0.0003, 0.0020, 0.0038, 0.0001, 0.0087, 0.0004, 0.0077, 0.0001, 0.0004, 0.0003, 0.0005, 0.0006, 0.0015, 0.0004, 0.0203, 0.0011, 0.0003, 0.0031, 0.0008, 0.0069, 0.0115, 0.0003, 0.0183, 0.0311, 0.0007, 0.0002, 7.9427e-5, 0.0211, 0.0082, 0.0229, 0.0219, 0.0112, 0.0047, 0.0091, 0.0008, 0.0006, 0.0220, 0.0013, 0.0017, 0.0093, 0.0125, 0.0009, 0.0027, 0.0014, 0.0023, 0.0205, 0.0012, 0.0533, 0.0002, 0.0147, 5.2794e-5, 0.0176, 0.0070, 0.0010, 0.0103, 0.0051, 0.0013, 0.0001, 0.0006, 0.0076, 0.0037, 0.0160, 0.0024, 0.0241, 0.0052, 0.0006, 0.0084, 0.0020, 0.0256, 0.0113, 0.0052, 0.0009, 0.0193, 0.0041, 0.0015, 0.0047, 0.0133, 0.0012, 0.0005, 0.0158, 0.0001, 0.0017, 0.0080, 0.0049, 0.0056, 0.0120, 0.0001, 8.6246e-5, 0.0113, 0.0120, 0.0149, 0.0044, 0.0074, 0.0137, 0.0006, 0.0004, 0.0168, 0.0018, 0.0012, 0.0011, 0.0002, 0.0100, 0.0088, 0.0150, 0.0072, 0.0163, 0.0167, 0.0047]]
\ No newline at end of file
[[ 3.9834e-5, 0.1086, 0.0069, 5.1373e-5, 5.7987e-5, 0.0010, 0.0180, 0.0201, 0.0008, 0.0131, 0.0196, 0.0003, 0.0003, 0.0058, 0.0133, 0.0251, 0.0039, 0.0057, 0.0008, 9.774e-5, 1.7109e-5, 2.7785e-5, 3.2956e-5, 0.0002, 0.0037, 2.939e-5, 0.0007, 0.0010, 2.02e-5, 0.0096, 8.0163e-5, 0.0073, 1.5375e-5, 0.0001, 0.0002, 3.8609e-5, 0.0003, 0.0003, 0.0001, 0.0379, 0.0001, 0.0002, 0.0042, 0.0004, 0.0074, 0.0104, 0.0002, 0.0199, 0.0318, 0.0002, 3.3676e-5, 3.7459e-5, 0.0111, 0.0038, 0.0218, 0.0097, 0.0129, 0.0030, 0.0066, 0.0003, 0.0002, 0.0143, 0.0001, 0.0005, 0.0092, 0.0138, 0.0003, 0.0024, 0.0010, 0.0011, 0.0237, 0.0003, 0.1169, 1.4753e-5, 0.0059, 1.5873e-5, 0.0397, 0.0037, 0.0006, 0.0083, 0.0032, 0.0004, 2.7196e-5, 6.8669e-5, 0.0062, 0.0047, 0.0064, 0.0003, 0.0077, 0.0061, 0.0005, 0.0112, 0.0006, 0.0114, 0.0042, 0.0026, 0.0007, 0.0264, 0.0067, 0.0007, 0.0052, 0.0147, 0.0012, 0.0002, 0.0177, 5.0518e-5, 0.0027, 0.0107, 0.0020, 0.0038, 0.0091, 2.2127e-5, 7.6618e-6, 0.0154, 0.0095, 0.0286, 0.0015, 0.0077, 0.0132, 0.0003, 4.8722e-5, 0.0087, 0.0006, 0.0006, 0.0006, 3.0554e-5, 0.0053, 0.0082, 0.0057, 0.0070, 0.0148, 0.0108, 0.0027]]
\ No newline at end of file
...@@ -43,12 +43,23 @@ public class Inference { ...@@ -43,12 +43,23 @@ public class Inference {
} }
public void inference(MultiLayerNetwork model, ArrayList<String> testFile) throws IOException { public void inference(MultiLayerNetwork model, ArrayList<String> testFile, String model_name) throws IOException {
int height = 2048; int height = 0;
int width = 2048; int width = 0;
int channels = 3; int channels = 0;
if (model_name.equals("model_1")) {
height = 2048;
width = 2048;
channels = 3;
}
else if (model_name.equals("model_2")) {
height = 512;
width = 512;
channels = 3;
}
for (int i=0; i < testFile.size(); i++) { for (int i = 0; i < testFile.size(); i++) {
String filePath = testFile.get(i); String filePath = testFile.get(i);
// ImageData image_1 = new ImageData().getData(filePath); // ImageData image_1 = new ImageData().getData(filePath);
...@@ -76,12 +87,13 @@ public class Inference { ...@@ -76,12 +87,13 @@ public class Inference {
System.out.println(output); System.out.println(output);
String input_file = String.valueOf(i); String input_file = String.valueOf(i);
writeOutput(1, output, input_file); writeOutput(model_name, output, input_file);
} }
} }
public void writeOutput(int model_num, String output, String input) {
String fileName = "Dataset/Output/Model_" + model_num + "/output_" + input + ".txt"; public void writeOutput(String model_name, String output, String input) {
String fileName = "Dataset/Output/" + model_name + "/output_" + input + ".txt";
try { try {
BufferedWriter writer = new BufferedWriter(new FileWriter(fileName, false)); BufferedWriter writer = new BufferedWriter(new FileWriter(fileName, false));
......
...@@ -14,6 +14,8 @@ public class Main { ...@@ -14,6 +14,8 @@ public class Main {
// } // }
// System.out.println(preprocess.length); // System.out.println(preprocess.length);
// Using image to test deep model Resnet and VGG
ArrayList<String> filepath = new ArrayList<>(); ArrayList<String> filepath = new ArrayList<>();
String temp = "Dataset/DCImage/1.jpg"; String temp = "Dataset/DCImage/1.jpg";
filepath.add(temp); filepath.add(temp);
...@@ -25,8 +27,11 @@ public class Main { ...@@ -25,8 +27,11 @@ public class Main {
// ImageData test = new ImageData(); // ImageData test = new ImageData();
// test.getData(temp); // test.getData(temp);
// Call a model inference - args: load model, list string path of test file, model name
Inference test_infer = new Inference(); Inference test_infer = new Inference();
test_infer.inference(test_infer.getResnetModel(), filepath); // test_infer.inference(test_infer.getResnetModel(), filepath, "model_1");
test_infer.inference(test_infer.getVGGModel(), filepath, "model_2");
......
No preview for this file type
No preview for this file type
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment