Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File file = new File("Java.jpg");
- Image image = new Image(file.toURI().toString());
- imga.setImage(image);
- String modelpath = "C:\\Users\\AngruAdminAlex\\Documents\\inception_dec_2015";
- graphDef
- = readAllBytesOrExit(Paths.get(modelpath,
- "tensorflow_inception_graph.pb"));
- labels
- = readAllLinesOrExit(Paths.get(modelpath,
- "imagenet_comp_graph_label_strings.txt"));
- File file1 = new File("Java.jpg");
- String imagepath = "Java.jpg";
- System.out.println(
- "Image
- Path: " + imagepath); BufferedImage img = ImageIO.read(file1); //read
- image System
- .out.println("Reading complete.");
- byte[] imageBytes
- = readAllBytesOrExit(Paths.get(imagepath));
- byte data[] = imageBytes;
- FileOutputStream out = new FileOutputStream("buffer.rawfile");
- out.write(data);
- out.close();
- try (Tensor image1
- = Tensor.create(imageBytes)) {
- float[] labelProbabilities
- = executeInceptionGraph(graphDef, image1);
- int bestLabelIdx
- = maxIndex(labelProbabilities);
- System.out.println(String.format( "BEST
- MATCH:
- % s( % .2f likely)", labels.get(bestLabelIdx),
- labelProbabilities[bestLabelIdx] * 100f
- )); results.setText(
- String.format("BEST MATCH: %s (%.2f likely)",
- labels.get(bestLabelIdx), labelProbabilities[bestLabelIdx] * 100f));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement