DL4JVGG16Net implements ObjectRecogniser { @Override public List<RecognisedObject> recognise(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { INDArray image = imageLoader.asMatrix(stream); preProcessor.transform(image); INDArray[] output = model.output(false, image); return predict(output[0]); }  Set<MediaType> getSupportedMimes(); @Override boolean isAvailable(); @Override void checkInitialization(InitializableProblemHandler problemHandler); @Override void initialize(Map<String, Param> params); @Override List<RecognisedObject> recognise(InputStream stream, ContentHandler handler,
                                            Metadata metadata, ParseContext context); static final Set<MediaType> SUPPORTED_MIMES; }
@Test public void recognise() throws Exception { TikaConfig config = null; try (InputStream is = getClass().getResourceAsStream("dl4j-vgg16-config.xml")) { config = new TikaConfig(is); } catch (Exception e) { if (e.getMessage() != null && (e.getMessage().contains("Connection refused") || e.getMessage().contains("connect timed out"))) { assumeTrue("skipping test because of connection issue", false); } throw e; } assumeTrue("something went wrong loading tika config", config != null); Tika tika = new Tika(config); Metadata md = new Metadata(); try (InputStream is = getClass().getResourceAsStream("lion.jpg")) { tika.parse(is, md); } String[] objects = md.getValues("OBJECT"); boolean found = false; for (String object : objects) { if (object.contains("lion")) { found = true; break; } } assertTrue(found); }