tensorflow/lite/g3doc/api_docs/python/tflite_support/task/vision/ImageClassifier.md
page_type: reference description: Class that performs classification on images.
<link rel="stylesheet" href="/site-assets/css/style.css"> <!-- DO NOT EDIT! Automatically generated file. --> <div itemscope itemtype="http://developers.google.com/ReferenceObject"> <meta itemprop="name" content="tflite_support.task.vision.ImageClassifier" /> <meta itemprop="path" content="Stable" /> <meta itemprop="property" content="__init__"/> <meta itemprop="property" content="classify"/> <meta itemprop="property" content="create_from_file"/> <meta itemprop="property" content="create_from_options"/> </div>View source on GitHub
Class that performs classification on images.
<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link"> <code>tflite_support.task.vision.ImageClassifier( options: <a href="../../../tflite_support/task/vision/ImageClassifierOptions"><code>tflite_support.task.vision.ImageClassifierOptions</code></a>, classifier: _CppImageClassifier ) -> None </code></pre> <!-- Placeholder for "Used in" --> <!-- Tabular view --> <table class="responsive fixed orange"> <colgroup><col width="214px"><col></colgroup> <tr><th colspan="2"><h2 class="add-link">Attributes</h2></th></tr> <tr> <td> `options`<a id="options"></a> </td> <td> </td> </tr> </table><a target="_blank" class="external" href="https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/vision/image_classifier.py#L95-L123">View source</a>
<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link"> <code>classify( image: <a href="../../../tflite_support/task/vision/TensorImage"><code>tflite_support.task.vision.TensorImage</code></a>, bounding_box: Optional[<a href="../../../tflite_support/task/processor/BoundingBox"><code>tflite_support.task.processor.BoundingBox</code></a>] = None ) -> <a href="../../../tflite_support/task/processor/ClassificationResult"><code>tflite_support.task.processor.ClassificationResult</code></a> </code></pre>Performs classification on the provided TensorImage.
<!-- Tabular view --> <table class="responsive fixed orange"> <colgroup><col width="214px"><col></colgroup> <tr><th colspan="2">Args</th></tr> <tr> <td> `image` </td> <td> Tensor image, used to extract the feature vectors. </td> </tr><tr> <td> `bounding_box` </td> <td> Bounding box, optional. If set, performed feature vector extraction only on the provided region of interest. Note that the region of interest is not clamped, so this method will fail if the region is out of bounds of the input image. </td> </tr> </table> <!-- Tabular view --> <table class="responsive fixed orange"> <colgroup><col width="214px"><col></colgroup> <tr><th colspan="2">Returns</th></tr> <tr class="alt"> <td colspan="2"> classification result. </td> </tr> </table> <!-- Tabular view --> <table class="responsive fixed orange"> <colgroup><col width="214px"><col></colgroup> <tr><th colspan="2">Raises</th></tr> <tr> <td> `ValueError` </td> <td> If any of the input arguments is invalid. </td> </tr><tr> <td> `RuntimeError` </td> <td> If failed to run classification. </td> </tr> </table> <h3 id="create_from_file"><code>create_from_file</code></h3><a target="_blank" class="external" href="https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/vision/image_classifier.py#L58-L74">View source</a>
<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link"> <code>@classmethod</code> <code>create_from_file( file_path: str ) -> 'ImageClassifier' </code></pre>Creates the ImageClassifier object from a TensorFlow Lite model.
<a target="_blank" class="external" href="https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/vision/image_classifier.py#L76-L93">View source</a>
<pre class="devsite-click-to-copy prettyprint lang-py tfo-signature-link"> <code>@classmethod</code> <code>create_from_options( options: <a href="../../../tflite_support/task/vision/ImageClassifierOptions"><code>tflite_support.task.vision.ImageClassifierOptions</code></a> ) -> 'ImageClassifier' </code></pre>Creates the ImageClassifier object from image classifier options.