@Override
    public List<RecognisedObject> recognise(InputStream stream, ContentHandler handler,
                                            Metadata metadata, ParseContext context)
            throws IOException, SAXException, TikaException {

        INDArray image = preProcessImage(imageLoader.asImageMatrix(stream, false).getImage());
        INDArray scores = graph.outputSingle(image);
        List<RecognisedObject> result = new ArrayList<>();
        for (int i = 0; i < scores.length(); i++) {
            if (scores.getDouble(i) > minConfidence) {
                String label = labelMap.get(i);
                String id = i + "";
                result.add(new RecognisedObject(label, labelLang, id, scores.getDouble(i)));
                LOG.debug("Found Object {}", label);
            }
        }
        return result;
    }
@Test
    public void recognise() throws Exception {
        assumeFalse(SystemUtils.OS_ARCH.equals("aarch64"), "doesn't yet work on aarch64");
        TikaConfig config = null;
        try (InputStream is = getClass().getResourceAsStream("dl4j-inception3-config.xml")) {
            config = new TikaConfig(is);
        } catch (Exception e) {
            if (e.getMessage() != null && (e.getMessage().contains("Connection refused") ||
                    e.getMessage().contains("connect timed out") || e.getMessage().contains("403 for URL"))) {
                assumeTrue(false, "skipping test because of connection issue");
            }
            throw e;
        }
        assumeTrue(config != null, "something went wrong loading tika config");
        Tika tika = new Tika(config);
        Metadata md = new Metadata();
        try (InputStream is = getClass().getResourceAsStream("cat.jpg")) {
            tika.parse(is, md);
        }
        String[] objects = md.getValues("OBJECT");
        boolean found = false;
        for (String object : objects) {
            if (object.contains("_cat")) {
                found = true;
                break;
            }
        }
        assertTrue(found);
    }