[
https://issues.apache.org/jira/browse/TIKA-2298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15940472#comment-15940472
]
ASF GitHub Bot commented on TIKA-2298:
--------------------------------------
GitHub user asmehra95 opened a pull request:
https://github.com/apache/tika/pull/159
fix for TIKA-2298 contributed by asmehra95
I have imported VGG16 model into Apache tika using deeplearning4j.
The usage of this recogniser is very similar to TensorFlowRESTrecogniser
but it doesn't require any external setup, like running RESTservice in as in
case of TensorFlowRESTrecogniser.
You can read more about TensorFlowRESTrecogniser at
https://wiki.apache.org/tika/TikaAndVision
To use the DL4JImageRecogniser set
class param to org.apache.tika.parser.recognition.dl4j.DL4JImageRecogniser
modelType to VGG16
sample configuration is given below for refference.
<?xml version="1.0" encoding="UTF-8"?>
<properties>
<parsers>
<parser
class="org.apache.tika.parser.recognition.ObjectRecognitionParser">
<mime>image/jpeg</mime>
<params>
<param name="topN" type="int">5</param>
<param name="minConfidence" type="double">0.015</param>
<param name="class"
type="string">org.apache.tika.parser.recognition.dl4j.DL4JImageRecogniser</param>
<param name="modelType"
type="string">VGG16</param>
</params>
</parser>
</parsers>
</properties>
Save the configuration at :
tika-parsers/src/test/resources/org/apache/tika/parser/recognition/tika-config-tflow-rest
To run it, build the project and move to root directory of the project and
run the command
java -Xmx3G -jar tika-app/target/tika-app-1.14.jar
--config=tika-parsers/src/test/resources/org/apache/tika/parser/recognition/tika-config-tflow-rest.xml
<path to your image file>
-Xmx3G is required because VGG16 model requires quite a lot of memory to
run. If your system is not able to run it, you may try to pump up the memory
further
Once the model runs, it automatically downloads the model file using helper
functions of DL4J locally at .dl4j/trainedModels
To speed up the process in future, once the model is loaded from original
hash files, it is serialized and saved on disk at
.dl4j/trainedModels/tikaPreprocessed which significantly reduces
the resource usage (specially memory consumption) for future loads.
For more details you can red this gist:
https://gist.github.com/asmehra95/a16c49ec91f7f0d7b39c5bf6c2483e4d
Issue Link:
https://issues.apache.org/jira/browse/TIKA-2298
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/asmehra95/tika master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/tika/pull/159.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #159
----
commit a5cd6f42dcded603f2b6de9476280c4bd95b6806
Author: asmehra95 <[email protected]>
Date: 2017-03-24T14:21:40Z
Added dependencies for DL4JImageRecogniser parser
commit f777f21b47c8d122e6b7a0819b44977f1d571c59
Author: asmehra95 <[email protected]>
Date: 2017-03-24T14:28:54Z
Imported VGG16 model via deeplearning4j
----
> To improve object recognition parser so that it may work without external
> RESTful service setup
> -----------------------------------------------------------------------------------------------
>
> Key: TIKA-2298
> URL: https://issues.apache.org/jira/browse/TIKA-2298
> Project: Tika
> Issue Type: Improvement
> Components: parser
> Affects Versions: 1.14
> Reporter: Avtar Singh
> Labels: ObjectRecognitionParser
> Fix For: 1.15
>
> Original Estimate: 672h
> Remaining Estimate: 672h
>
> When ObjectRecognitionParser was built to do image recognition, there wasn't
> good support for Java frameworks. All the popular neural networks were in
> C++ or python. Since there was nothing that runs within JVM, we tried
> several ways to glue them to Tika (like CLI, JNI, gRPC, REST).
> However, this game is changing slowly now. Deeplearning4j, the most famous
> neural network library for JVM, now supports importing models that are
> pre-trained in python/C++ based kits [5].
> *Improvement:*
> It will be nice to have an implementation of ObjectRecogniser that
> doesn't require any external setup(like installation of native libraries or
> starting REST services). Reasons: easy to distribute and also to cut the IO
> time.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)