Class TensorflowImageRecParser
- java.lang.Object
-
- org.apache.tika.parser.external.ExternalParser
-
- org.apache.tika.parser.recognition.tf.TensorflowImageRecParser
-
- All Implemented Interfaces:
Serializable,org.apache.tika.config.Initializable,org.apache.tika.parser.Parser,ObjectRecogniser
public class TensorflowImageRecParser extends org.apache.tika.parser.external.ExternalParser implements ObjectRecogniser
This is an implementation ofObjectRecogniserpowered by Tensorflow convolutional neural network (CNN). This implementation binds to Python API usingExternalParser.
// 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:
TensorflowRESTRecogniser, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TensorflowImageRecParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckInitialization(org.apache.tika.config.InitializableProblemHandler handler)Set<org.apache.tika.mime.MediaType>getSupportedMimes()The mimes supported by this recogniservoidinitialize(Map<String,org.apache.tika.config.Param> params)This is the hook for configuring the recogniserbooleanisAvailable()Is this service availableList<RecognisedObject>recognise(InputStream stream, ContentHandler handler, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context)Recognise the objects in the stream
-
-
-
Method Detail
-
getSupportedMimes
public Set<org.apache.tika.mime.MediaType> 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
public void initialize(Map<String,org.apache.tika.config.Param> params) throws org.apache.tika.exception.TikaConfigException
Description copied from interface:ObjectRecogniserThis is the hook for configuring the recogniser- Specified by:
initializein interfaceorg.apache.tika.config.Initializable- Specified by:
initializein interfaceObjectRecogniser- Parameters:
params- configuration instance in the form of context- Throws:
org.apache.tika.exception.TikaConfigException- when there is an issue with configuration
-
checkInitialization
public void checkInitialization(org.apache.tika.config.InitializableProblemHandler handler) throws org.apache.tika.exception.TikaConfigException- Specified by:
checkInitializationin interfaceorg.apache.tika.config.Initializable- Throws:
org.apache.tika.exception.TikaConfigException
-
recognise
public List<RecognisedObject> recognise(InputStream stream, ContentHandler handler, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context) throws IOException, SAXException, org.apache.tika.exception.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 occursorg.apache.tika.exception.TikaException- any generic error
-
-