Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Add documentation for image hash pipeline #240

davidmezzetti1d41192b44de
diff --git a/docs/pipeline/image/imagehash.md b/docs/pipeline/image/imagehash.md
new file mode 100644
index 00000000..318d1acb
--- /dev/null
+++ b/docs/pipeline/image/imagehash.md
@@ -0,0 +1,62 @@
+# ImageHash
+
+![pipeline](../../images/pipeline.png#only-light)
+![pipeline](../../images/pipeline-dark.png#only-dark)
+
+The image hash pipeline generates perceptual image hashes. These hashes can be used to detect near-duplicate images. This method is not backed by machine learning models and not intended to find conceptually similar images.
+
+## Example
+
+The following shows a simple example using this pipeline.
+
+```python
+from txtai.pipeline import ImageHash
+
+# Create and run pipeline
+ihash = ImageHash()
+ihash("path to image file")
+```
+
+## Configuration-driven example
+
+Pipelines are run with Python or configuration. Pipelines can be instantiated in [configuration](../../../api/configuration/#pipeline) using the lower case name of the pipeline. Configuration-driven pipelines are run with [workflows](../../../workflow/#configuration-driven-example) or the [API](../../../api#local-instance).
+
+### config.yml
+```yaml
+# Create pipeline using lower case class name
+imagehash:
+
+# Run pipeline with workflow
+workflow:
+ imagehash:
+ tasks:
+ - action: imagehash
+```
+
+### Run with Workflows
+
+```python
+from txtai.api import API
+
+# Create and run pipeline with workflow
+app = API("config.yml")
+list(app.workflow("imagehash", ["path to image file"]))
+```
+
+### Run with API
+
+```bash
+CONFIG=config.yml uvicorn "txtai.api:app" &
+
+curl \
+ -X POST "http://localhost:8000/workflow" \
+ -H "Content-Type: application/json" \
+ -d '{"name":"imagehash", "elements":["path to image file"]}'
+```
+
+## Methods
+
+Python documentation for the pipeline.
+
+### ::: txtai.pipeline.ImageHash.__init__
+### ::: txtai.pipeline.ImageHash.__call__
diff --git a/docs/pipeline/index.md b/docs/pipeline/index.md
index 6e28a4ec..b90e3589 100644
--- a/docs/pipeline/index.md
+++ b/docs/pipeline/index.md
@@ -19,6 +19,7 @@ The following is a list of the default pipelines available in txtai.
- [Text extraction](data/textractor)
- Image
- [Caption](image/caption)
+ - [Image Hash](image/imagehash)
- [Objects](image/objects)
- Text
- [Entity](text/entity)