<div align="center">
<img src="https://github.com/d1pankarmedhi/picachain/assets/136924835/3a299c21-6590-4ee1-a3c1-73a92653f21e" height=150></img>
<h3>⚡️ Build quick LLM pipelines for all your image specific tasks</h3>
![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)
[![PyPi license](https://badgen.net/pypi/license/pip/)]() [![PyPI version fury.io](https://badge.fury.io/py/picachain.svg)](https://pypi.python.org/pypi/picachain/)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/picachain.svg?style=social&label=Follow%20%40Picachain)](https://twitter.com/picachain)
</div>
**Picachain** is a framework for building complex non language pipelines for your LLM application. Build pipelines for your images, charts and graphs, parse, extract and generate using opensource models with ease, thanks to support for huggingface and diffusion libraries.
## 🌉 Things you can build with Picachain
- **Image Search Engines**: Build quick search engines for your images using ChromaDB and Pinecone for vector storage and retrieval.
- **Image Generation**: Generate images with ease, thanks to support of Stable Diffusion, SDXL and SDXLturbo.
- **Chart Parsing**: Parse chart/graph from images and extract meaningful data and build a question-answering system on top of this using an LLM.
## 📌 Install Picachain
```bash
pip install picachain
```
## 🥇 Example Usage
### Build a quick image search engine
Use **ChromaDB** or **Pinecone** for storage with **CLIP** embeddings.
Check out a demo [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1FbruIGMBrD7VW5jCHStHzGlsEuigbS0q?usp=sharing)
```python
from PIL import Image
import matplotlib.pyplot as plt
# import from picachain
from picachain.chains.image.search import ImageSearchChain
from picachain.datastore import ChromaStore, PineconeStore
from picachain.embedding import ClipEmbedding
from picachain.retriever import ImageRetriever
```
```python
img = Image.open("image.png") # query image
images = [...] # list of images
```
```python
# initiate embedding, datastore and retriever
embedding = ClipEmbedding()
datastore = ChromaStore("test-collection")
retriever = ImageRetriever(datastore, embedding, images)
img_chain = ImageSearchChain.from_image(retriever, embedding, img)
result = img_chain.similar_images(top_k=3)
for img, score in result: # [(img, score), (img, score)]
plt.imshow(img)
plt.show()
```
### Build Chart Conversation Chain
```python
from dotenv import load_dotenv
from picachain.chains.unstructured.charts import ChartConversationChain
from picachain.models.openai.openai import OpenAI_Model
load_dotenv()
```
```pyhton
chart_conv_chain = ChartConversationChain(
chart="/home/home/dev/picachain/data/chart1.png", llm=OpenAI_Model()
)
response = chart_conv_chain.run(query="What do I eat?")
print(response)
```
## 💡 Contributing
As an open-source project, we are open to all kinds of contribution, be it through code, documentation, issues, bugs, or even feature suggestions.
Feel free to check out [Contribution](/CONTRIBUTION.md) guide for more details.
## 🔧 Dependencies
We use poetry as the package manager. Make sure to refer to `pyproject.toml` for more details on dependencies.
```bash
cd picachain
pip install poetry
poetry install
```
Raw data
{
"_id": null,
"home_page": "https://github.com/d1pankarmedhi/picachain",
"name": "picachain",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "python, search-engine, chromadb, image, search, packages, poetry, python-packages, pinecone",
"author": "d1pankarmedhi",
"author_email": "dipankarmedhi11@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/fd/6e/9b7c811099de605b7f4b33a699a0e16b926b4bce60bde8bb09d9db682009/picachain-0.1.37.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n<img src=\"https://github.com/d1pankarmedhi/picachain/assets/136924835/3a299c21-6590-4ee1-a3c1-73a92653f21e\" height=150></img>\n<h3>\u26a1\ufe0f Build quick LLM pipelines for all your image specific tasks</h3>\n\n![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)\n\n[![PyPi license](https://badgen.net/pypi/license/pip/)]() [![PyPI version fury.io](https://badge.fury.io/py/picachain.svg)](https://pypi.python.org/pypi/picachain/)\n[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/picachain.svg?style=social&label=Follow%20%40Picachain)](https://twitter.com/picachain)\n\n\n\n</div>\n\n\n**Picachain** is a framework for building complex non language pipelines for your LLM application. Build pipelines for your images, charts and graphs, parse, extract and generate using opensource models with ease, thanks to support for huggingface and diffusion libraries.\n\n## \ud83c\udf09 Things you can build with Picachain\n- **Image Search Engines**: Build quick search engines for your images using ChromaDB and Pinecone for vector storage and retrieval. \n- **Image Generation**: Generate images with ease, thanks to support of Stable Diffusion, SDXL and SDXLturbo.\n- **Chart Parsing**: Parse chart/graph from images and extract meaningful data and build a question-answering system on top of this using an LLM.\n\n## \ud83d\udccc Install Picachain\n\n```bash\npip install picachain\n```\n\n## \ud83e\udd47 Example Usage\n\n### Build a quick image search engine\n\nUse **ChromaDB** or **Pinecone** for storage with **CLIP** embeddings.\nCheck out a demo [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1FbruIGMBrD7VW5jCHStHzGlsEuigbS0q?usp=sharing)\n\n\n```python\nfrom PIL import Image\nimport matplotlib.pyplot as plt\n\n# import from picachain\nfrom picachain.chains.image.search import ImageSearchChain\nfrom picachain.datastore import ChromaStore, PineconeStore\nfrom picachain.embedding import ClipEmbedding\nfrom picachain.retriever import ImageRetriever\n```\n\n```python\nimg = Image.open(\"image.png\") # query image\nimages = [...] # list of images\n```\n\n```python\n# initiate embedding, datastore and retriever\nembedding = ClipEmbedding()\ndatastore = ChromaStore(\"test-collection\")\nretriever = ImageRetriever(datastore, embedding, images)\nimg_chain = ImageSearchChain.from_image(retriever, embedding, img)\nresult = img_chain.similar_images(top_k=3)\n\nfor img, score in result: # [(img, score), (img, score)]\n plt.imshow(img)\n plt.show()\n\n```\n\n### Build Chart Conversation Chain\n\n```python\nfrom dotenv import load_dotenv\nfrom picachain.chains.unstructured.charts import ChartConversationChain\nfrom picachain.models.openai.openai import OpenAI_Model\nload_dotenv()\n```\n```pyhton\nchart_conv_chain = ChartConversationChain(\n chart=\"/home/home/dev/picachain/data/chart1.png\", llm=OpenAI_Model()\n)\nresponse = chart_conv_chain.run(query=\"What do I eat?\")\nprint(response)\n```\n\n## \ud83d\udca1 Contributing\nAs an open-source project, we are open to all kinds of contribution, be it through code, documentation, issues, bugs, or even feature suggestions. \n\nFeel free to check out [Contribution](/CONTRIBUTION.md) guide for more details.\n\n## \ud83d\udd27 Dependencies\nWe use poetry as the package manager. Make sure to refer to `pyproject.toml` for more details on dependencies. \n\n```bash\ncd picachain\npip install poetry\npoetry install \n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Build quick LLM pipelines for image specific tasks.",
"version": "0.1.37",
"project_urls": {
"Homepage": "https://github.com/d1pankarmedhi/picachain",
"Repository": "https://github.com/d1pankarmedhi/picachain"
},
"split_keywords": [
"python",
" search-engine",
" chromadb",
" image",
" search",
" packages",
" poetry",
" python-packages",
" pinecone"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6cc99ea810c8d8ca61a5da4346a5fa4e9f986cd2bc3a081ec9b70d02521f391b",
"md5": "c31155db37a806a4ab88119d66a8dfc6",
"sha256": "63bea92563dc9e058ebabdc93f2d69b5d7942ca152f4223d743ccecc6f6acf91"
},
"downloads": -1,
"filename": "picachain-0.1.37-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c31155db37a806a4ab88119d66a8dfc6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 21586,
"upload_time": "2024-04-29T18:08:47",
"upload_time_iso_8601": "2024-04-29T18:08:47.416577Z",
"url": "https://files.pythonhosted.org/packages/6c/c9/9ea810c8d8ca61a5da4346a5fa4e9f986cd2bc3a081ec9b70d02521f391b/picachain-0.1.37-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fd6e9b7c811099de605b7f4b33a699a0e16b926b4bce60bde8bb09d9db682009",
"md5": "ca2232837c5c147d3a42e1d0f1290a2b",
"sha256": "282df4db19ce7ac13e57e6143d0de5407c4d0e575b2e325f057d17799d3a2424"
},
"downloads": -1,
"filename": "picachain-0.1.37.tar.gz",
"has_sig": false,
"md5_digest": "ca2232837c5c147d3a42e1d0f1290a2b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 12880,
"upload_time": "2024-04-29T18:08:51",
"upload_time_iso_8601": "2024-04-29T18:08:51.280359Z",
"url": "https://files.pythonhosted.org/packages/fd/6e/9b7c811099de605b7f4b33a699a0e16b926b4bce60bde8bb09d9db682009/picachain-0.1.37.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-29 18:08:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "d1pankarmedhi",
"github_project": "picachain",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "annotated-types",
"specs": [
[
"==",
"0.6.0"
]
]
},
{
"name": "anyio",
"specs": [
[
"==",
"4.3.0"
]
]
},
{
"name": "asgiref",
"specs": [
[
"==",
"3.8.1"
]
]
},
{
"name": "backoff",
"specs": [
[
"==",
"2.2.1"
]
]
},
{
"name": "bcrypt",
"specs": [
[
"==",
"4.1.2"
]
]
},
{
"name": "build",
"specs": [
[
"==",
"1.2.1"
]
]
},
{
"name": "cachetools",
"specs": [
[
"==",
"5.3.3"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2024.2.2"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.3.2"
]
]
},
{
"name": "chroma-hnswlib",
"specs": [
[
"==",
"0.7.3"
]
]
},
{
"name": "chromadb",
"specs": [
[
"==",
"0.4.24"
]
]
},
{
"name": "click",
"specs": [
[
"==",
"8.1.7"
]
]
},
{
"name": "colorama",
"specs": [
[
"==",
"0.4.6"
]
]
},
{
"name": "coloredlogs",
"specs": [
[
"==",
"15.0.1"
]
]
},
{
"name": "deprecated",
"specs": [
[
"==",
"1.2.14"
]
]
},
{
"name": "exceptiongroup",
"specs": [
[
"==",
"1.2.0"
]
]
},
{
"name": "fastapi",
"specs": [
[
"==",
"0.110.0"
]
]
},
{
"name": "filelock",
"specs": [
[
"==",
"3.13.3"
]
]
},
{
"name": "flatbuffers",
"specs": [
[
"==",
"24.3.25"
]
]
},
{
"name": "fsspec",
"specs": [
[
"==",
"2024.3.1"
]
]
},
{
"name": "google-auth",
"specs": [
[
"==",
"2.29.0"
]
]
},
{
"name": "googleapis-common-protos",
"specs": [
[
"==",
"1.63.0"
]
]
},
{
"name": "graphlib-backport",
"specs": [
[
"==",
"1.1.0"
]
]
},
{
"name": "grpcio",
"specs": [
[
"==",
"1.62.1"
]
]
},
{
"name": "h11",
"specs": [
[
"==",
"0.14.0"
]
]
},
{
"name": "httptools",
"specs": [
[
"==",
"0.6.1"
]
]
},
{
"name": "huggingface-hub",
"specs": [
[
"==",
"0.22.1"
]
]
},
{
"name": "humanfriendly",
"specs": [
[
"==",
"10.0"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.6"
]
]
},
{
"name": "importlib-metadata",
"specs": [
[
"==",
"7.0.0"
]
]
},
{
"name": "importlib-resources",
"specs": [
[
"==",
"6.4.0"
]
]
},
{
"name": "jinja2",
"specs": [
[
"==",
"3.1.3"
]
]
},
{
"name": "kubernetes",
"specs": [
[
"==",
"29.0.0"
]
]
},
{
"name": "markupsafe",
"specs": [
[
"==",
"2.1.5"
]
]
},
{
"name": "mmh3",
"specs": [
[
"==",
"4.1.0"
]
]
},
{
"name": "monotonic",
"specs": [
[
"==",
"1.6"
]
]
},
{
"name": "mpmath",
"specs": [
[
"==",
"1.3.0"
]
]
},
{
"name": "networkx",
"specs": [
[
"==",
"3.1"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"1.24.4"
]
]
},
{
"name": "nvidia-cublas-cu12",
"specs": [
[
"==",
"12.1.3.1"
]
]
},
{
"name": "nvidia-cuda-cupti-cu12",
"specs": [
[
"==",
"12.1.105"
]
]
},
{
"name": "nvidia-cuda-nvrtc-cu12",
"specs": [
[
"==",
"12.1.105"
]
]
},
{
"name": "nvidia-cuda-runtime-cu12",
"specs": [
[
"==",
"12.1.105"
]
]
},
{
"name": "nvidia-cudnn-cu12",
"specs": [
[
"==",
"8.9.2.26"
]
]
},
{
"name": "nvidia-cufft-cu12",
"specs": [
[
"==",
"11.0.2.54"
]
]
},
{
"name": "nvidia-curand-cu12",
"specs": [
[
"==",
"10.3.2.106"
]
]
},
{
"name": "nvidia-cusolver-cu12",
"specs": [
[
"==",
"11.4.5.107"
]
]
},
{
"name": "nvidia-cusparse-cu12",
"specs": [
[
"==",
"12.1.0.106"
]
]
},
{
"name": "nvidia-nccl-cu12",
"specs": [
[
"==",
"2.19.3"
]
]
},
{
"name": "nvidia-nvjitlink-cu12",
"specs": [
[
"==",
"12.4.99"
]
]
},
{
"name": "nvidia-nvtx-cu12",
"specs": [
[
"==",
"12.1.105"
]
]
},
{
"name": "oauthlib",
"specs": [
[
"==",
"3.2.2"
]
]
},
{
"name": "onnxruntime",
"specs": [
[
"==",
"1.17.1"
]
]
},
{
"name": "opentelemetry-api",
"specs": [
[
"==",
"1.24.0"
]
]
},
{
"name": "opentelemetry-exporter-otlp-proto-common",
"specs": [
[
"==",
"1.24.0"
]
]
},
{
"name": "opentelemetry-exporter-otlp-proto-grpc",
"specs": [
[
"==",
"1.24.0"
]
]
},
{
"name": "opentelemetry-instrumentation-asgi",
"specs": [
[
"==",
"0.45b0"
]
]
},
{
"name": "opentelemetry-instrumentation-fastapi",
"specs": [
[
"==",
"0.45b0"
]
]
},
{
"name": "opentelemetry-instrumentation",
"specs": [
[
"==",
"0.45b0"
]
]
},
{
"name": "opentelemetry-proto",
"specs": [
[
"==",
"1.24.0"
]
]
},
{
"name": "opentelemetry-sdk",
"specs": [
[
"==",
"1.24.0"
]
]
},
{
"name": "opentelemetry-semantic-conventions",
"specs": [
[
"==",
"0.45b0"
]
]
},
{
"name": "opentelemetry-util-http",
"specs": [
[
"==",
"0.45b0"
]
]
},
{
"name": "orjson",
"specs": [
[
"==",
"3.10.0"
]
]
},
{
"name": "overrides",
"specs": [
[
"==",
"7.7.0"
]
]
},
{
"name": "packaging",
"specs": [
[
"==",
"24.0"
]
]
},
{
"name": "pillow",
"specs": [
[
"==",
"10.2.0"
]
]
},
{
"name": "pinecone-client",
"specs": [
[
"==",
"3.2.1"
]
]
},
{
"name": "posthog",
"specs": [
[
"==",
"3.5.0"
]
]
},
{
"name": "protobuf",
"specs": [
[
"==",
"4.25.3"
]
]
},
{
"name": "pulsar-client",
"specs": [
[
"==",
"3.4.0"
]
]
},
{
"name": "pyasn1-modules",
"specs": [
[
"==",
"0.4.0"
]
]
},
{
"name": "pyasn1",
"specs": [
[
"==",
"0.6.0"
]
]
},
{
"name": "pydantic-core",
"specs": [
[
"==",
"2.16.3"
]
]
},
{
"name": "pydantic",
"specs": [
[
"==",
"2.6.4"
]
]
},
{
"name": "pypika",
"specs": [
[
"==",
"0.48.9"
]
]
},
{
"name": "pyproject-hooks",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "pyreadline3",
"specs": [
[
"==",
"3.4.1"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
"==",
"2.9.0.post0"
]
]
},
{
"name": "python-dotenv",
"specs": [
[
"==",
"1.0.1"
]
]
},
{
"name": "pyyaml",
"specs": [
[
"==",
"6.0.1"
]
]
},
{
"name": "regex",
"specs": [
[
"==",
"2023.12.25"
]
]
},
{
"name": "requests-oauthlib",
"specs": [
[
"==",
"2.0.0"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.31.0"
]
]
},
{
"name": "rsa",
"specs": [
[
"==",
"4.9"
]
]
},
{
"name": "safetensors",
"specs": [
[
"==",
"0.4.2"
]
]
},
{
"name": "setuptools",
"specs": [
[
"==",
"69.2.0"
]
]
},
{
"name": "six",
"specs": [
[
"==",
"1.16.0"
]
]
},
{
"name": "sniffio",
"specs": [
[
"==",
"1.3.1"
]
]
},
{
"name": "starlette",
"specs": [
[
"==",
"0.36.3"
]
]
},
{
"name": "sympy",
"specs": [
[
"==",
"1.12"
]
]
},
{
"name": "tenacity",
"specs": [
[
"==",
"8.2.3"
]
]
},
{
"name": "tokenizers",
"specs": [
[
"==",
"0.15.2"
]
]
},
{
"name": "tomli",
"specs": [
[
"==",
"2.0.1"
]
]
},
{
"name": "torch",
"specs": [
[
"==",
"2.2.2"
]
]
},
{
"name": "tqdm",
"specs": [
[
"==",
"4.66.2"
]
]
},
{
"name": "transformers",
"specs": [
[
"==",
"4.39.1"
]
]
},
{
"name": "triton",
"specs": [
[
"==",
"2.2.0"
]
]
},
{
"name": "typer",
"specs": [
[
"==",
"0.11.1"
]
]
},
{
"name": "typing-extensions",
"specs": [
[
"==",
"4.10.0"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.2.1"
]
]
},
{
"name": "uvicorn",
"specs": [
[
"==",
"0.29.0"
]
]
},
{
"name": "uvloop",
"specs": [
[
"==",
"0.19.0"
]
]
},
{
"name": "watchfiles",
"specs": [
[
"==",
"0.21.0"
]
]
},
{
"name": "websocket-client",
"specs": [
[
"==",
"1.7.0"
]
]
},
{
"name": "websockets",
"specs": [
[
"==",
"12.0"
]
]
},
{
"name": "wrapt",
"specs": [
[
"==",
"1.16.0"
]
]
},
{
"name": "zipp",
"specs": [
[
"==",
"3.18.1"
]
]
}
],
"lcname": "picachain"
}