Class TensorflowImageRecParser
java.lang.Object
org.apache.tika.parser.external.ExternalParser
org.apache.tika.parser.recognition.tf.TensorflowImageRecParser
- All Implemented Interfaces:
Serializable,Initializable,Parser,ObjectRecogniser
This is an implementation of
// NOTE: This is a proof of concept for an efficient implementation using JNI binding to Tensorflow's C++ api.
ObjectRecogniser powered by
Tensorflow
convolutional neural network (CNN). This implementation binds to
Python API using ExternalParser.
// NOTE: This is a proof of concept for an efficient implementation using JNI binding to Tensorflow's C++ api.
b>Environment Setup:
- Python must be available
- Tensorflow must be available for import by the python script. Setup Instructions here
- All dependencies of tensor flow (such as numpy) must also be available. Follow the image recognition guide and make sure it works
- Since:
- Apache Tika 1.14
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.tika.parser.external.ExternalParser
ExternalParser.LineConsumer -
Field Summary
Fields inherited from class org.apache.tika.parser.external.ExternalParser
INPUT_FILE_TOKEN, OUTPUT_FILE_TOKEN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThe mimes supported by this recogniservoidinitialize(Map<String, Param> params) This is the hook for configuring the recogniserbooleanIs this service availablerecognise(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) Recognise the objects in the streamMethods inherited from class org.apache.tika.parser.external.ExternalParser
check, check, getCommand, getIgnoredLineConsumer, getMetadataExtractionPatterns, getSupportedTypes, getSupportedTypes, parse, setCommand, setIgnoredLineConsumer, setMetadataExtractionPatterns, setSupportedTypes
-
Constructor Details
-
TensorflowImageRecParser
public TensorflowImageRecParser()
-
-
Method Details
-
getSupportedMimes
Description copied from interface:ObjectRecogniserThe mimes supported by this recogniser- Specified by:
getSupportedMimesin interfaceObjectRecogniser- Returns:
- set of mediatypes
-
isAvailable
public boolean isAvailable()Description copied from interface:ObjectRecogniserIs this service available- Specified by:
isAvailablein interfaceObjectRecogniser- Returns:
truewhen the service is available,falseotherwise
-
initialize
Description copied from interface:ObjectRecogniserThis is the hook for configuring the recogniser- Specified by:
initializein interfaceInitializable- Specified by:
initializein interfaceObjectRecogniser- Parameters:
params- configuration instance in the form of context- Throws:
TikaConfigException- when there is an issue with configuration
-
checkInitialization
- Specified by:
checkInitializationin interfaceInitializable- Parameters:
handler- if there is a problem and no custom initializableProblemHandler has been configured via Initializable parameters, this is called to respond.- Throws:
TikaConfigException
-
recognise
public List<RecognisedObject> recognise(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException Description copied from interface:ObjectRecogniserRecognise the objects in the stream- Specified by:
recognisein interfaceObjectRecogniser- Parameters:
stream- content streamhandler- tika's content handlermetadata- metadata instancecontext- parser context- Returns:
- List of
RecognisedObjects - Throws:
IOException- when an I/O error occursSAXException- when an issue with XML occursTikaException- any generic error
-