From 9f472e7636e57cfb59a16276c4c339045d13c02a Mon Sep 17 00:00:00 2001 From: raghavdixit99 Date: Sat, 2 Mar 2024 13:04:02 -0500 Subject: [PATCH] updated example --- README.md | 5 +- examples/imagebind_demo/README.md | 4 +- examples/imagebind_demo/app.py | 7 ++- examples/imagebind_demo/downloader.py | 6 +++ examples/imagebind_demo/main.ipynb | 78 --------------------------- 5 files changed, 14 insertions(+), 86 deletions(-) delete mode 100644 examples/imagebind_demo/main.ipynb diff --git a/README.md b/README.md index 4a74c7f6..c629da34 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,8 @@ If you're looking for in-depth tutorial-like examples, checkout the [tutorials]( | [Facial Recognition](./examples/facial_recognition) | Open In Colab | | [Accelerate Vector Search Applications Using OpenVINO](/tutorials/Accelerate-Vector-Search-Applications-Using-OpenVINO/) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/lancedb/vectordb-recipes/blob/main/tutorials/Accelerate-Vector-Search-Applications-Using-OpenVINO/clip_text_image_search.ipynb) [![local LLM](https://img.shields.io/badge/local-llm-green)](#)| [![Medium](https://img.shields.io/badge/Medium-12100E?style=for-the-badge&logo=medium&logoColor=white)](https://blog.lancedb.com/accelerate-vector-search-applications-using-openvino-51366eabf866)| | [Search Within Images](/examples/Contextual-Compression-with-RAG/) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/lancedb/vectordb-recipes/blob/main/examples/search-within-images-with-sam-and-clip/main.ipynb) [![local LLM](https://img.shields.io/badge/local-llm-green)](#) |[![Medium](https://img.shields.io/badge/Medium-12100E?style=for-the-badge&logo=medium&logoColor=white)](https://blog.lancedb.com/search-within-an-image-331b54e4285e)| -| [Contextual-Compression-with-RAG](/examples/Contextual-Compression-with-RAG/) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/lancedb/vectordb-recipes/blob/main/examples/Contextual-Compression-with-RAG/main.ipynb) [![local LLM](https://img.shields.io/badge/local-llm-green)](#) |[![Medium](https://img.shields.io/badge/Medium-12100E?style=for-the-badge&logo=medium&logoColor=white)](https://medium.com/etoai/enhance-rag-integrate-contextual-compression-and-filtering-for-precision-a29d4a810301) - - +| [Contextual-Compression-with-RAG](/examples/Contextual-Compression-with-RAG/) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/lancedb/vectordb-recipes/blob/main/examples/Contextual-Compression-with-RAG/main.ipynb) [![local LLM](https://img.shields.io/badge/local-llm-green)](#) |[![Medium](https://img.shields.io/badge/Medium-12100E?style=for-the-badge&logo=medium&logoColor=white)](https://medium.com/etoai/enhance-rag-integrate-contextual-compression-and-filtering-for-precision-a29d4a810301) | +| [Imagebind demo app](/examples/imagebind_demo/) | hf spaces| diff --git a/examples/imagebind_demo/README.md b/examples/imagebind_demo/README.md index 341206c3..3dd48aae 100644 --- a/examples/imagebind_demo/README.md +++ b/examples/imagebind_demo/README.md @@ -3,7 +3,9 @@ A gradio app showcasing multi-modal capabilities of Imagebind supported via lanceDB API ## Usage -you can run it locally by cloning the project as mentioned below, or access via Colab - Open In Colab +you can run it locally by cloning the project as mentioned below, or access via Spaces: + hf spaces + ```bash git clone https://github.com/lancedb/vectordb-recipes.git diff --git a/examples/imagebind_demo/app.py b/examples/imagebind_demo/app.py index adbe6f39..a5f01f26 100644 --- a/examples/imagebind_demo/app.py +++ b/examples/imagebind_demo/app.py @@ -7,7 +7,6 @@ model = get_registry().get("imagebind").create() - class TextModel(LanceModel): text: str image_uri: str = model.SourceField() @@ -63,21 +62,21 @@ def process_audio(inp_audio) -> str: im_to_at = gr.Interface( process_image, gr.Image(type="filepath", value=image_paths[0]), - ["text", "audio"], + [gr.Text(label="Output Text"), gr.Audio(label="Output Audio")], examples=image_paths, allow_flagging="never", ) txt_to_ia = gr.Interface( process_text, gr.Textbox(label="Enter a prompt:"), - ["image", "audio"], + [gr.Image(label="Output Image"), gr.Audio(label="Output Audio")], allow_flagging="never", examples=text_list, ) a_to_it = gr.Interface( process_audio, gr.Audio(type="filepath", value=audio_paths[0]), - ["image", "text"], + [gr.Image(label="Output Image"), gr.Text(label="Output Text")], examples=audio_paths, allow_flagging="never", ) diff --git a/examples/imagebind_demo/downloader.py b/examples/imagebind_demo/downloader.py index 9c650f7a..85e298f4 100644 --- a/examples/imagebind_demo/downloader.py +++ b/examples/imagebind_demo/downloader.py @@ -7,11 +7,17 @@ "https://github.com/raghavdixit99/assets/raw/main/bird_audio.wav", "https://github.com/raghavdixit99/assets/raw/main/dragon-growl-37570.wav", "https://github.com/raghavdixit99/assets/raw/main/car_audio.wav", + "https://github.com/raghavdixit99/assets/raw/main/acoustic-guitar.wav", + "https://github.com/raghavdixit99/assets/raw/main/witch-103635.wav", + "https://github.com/raghavdixit99/assets/raw/main/thunder-25689.wav" ] image_urls = [ "https://github.com/raghavdixit99/assets/assets/34462078/abf47cc4-d979-4aaa-83be-53a2115bf318", "https://github.com/raghavdixit99/assets/assets/34462078/93be928e-522b-4e37-889d-d4efd54b2112", "https://github.com/raghavdixit99/assets/assets/34462078/025deaff-632a-4829-a86c-3de6e326402f", + "https://github.com/raghavdixit99/assets/assets/34462078/a20bff32-155c-4bad-acf1-97856c493099", + "https://github.com/raghavdixit99/assets/assets/34462078/4f7dadd8-b38c-4c14-ac8a-5a2e74414f6a", + "https://github.com/raghavdixit99/assets/assets/34462078/ac11eeab-7b2b-4db3-981b-d5fed08d9bc2" ] base_path = os.path.dirname(os.path.abspath(__file__)) diff --git a/examples/imagebind_demo/main.ipynb b/examples/imagebind_demo/main.ipynb deleted file mode 100644 index bacae878..00000000 --- a/examples/imagebind_demo/main.ipynb +++ /dev/null @@ -1,78 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Imagebind demo\n", - "\n", - "This notebook runs the gradio interface for the demo app" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "!git clone https://github.com/lancedb/vectordb-recipes.git\n", - "%cd vectordb-recipes/examples/imagebind_demo\n", - "%pip install -r requirements.txt" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Image file downloaded successfully and saved as '/Users/raghavdixit/Desktop/open_source/vectordb-recipes_rd/examples/imagebind_demo/test_inputs/abf47cc4-d979-4aaa-83be-53a2115bf318.jpeg'.\n", - "Image file downloaded successfully and saved as '/Users/raghavdixit/Desktop/open_source/vectordb-recipes_rd/examples/imagebind_demo/test_inputs/93be928e-522b-4e37-889d-d4efd54b2112.jpeg'.\n", - "Image file downloaded successfully and saved as '/Users/raghavdixit/Desktop/open_source/vectordb-recipes_rd/examples/imagebind_demo/test_inputs/025deaff-632a-4829-a86c-3de6e326402f.jpeg'.\n", - "Audio file downloaded successfully and saved as '/Users/raghavdixit/Desktop/open_source/vectordb-recipes_rd/examples/imagebind_demo/test_inputs/bird_audio.wav'.\n", - "Audio file downloaded successfully and saved as '/Users/raghavdixit/Desktop/open_source/vectordb-recipes_rd/examples/imagebind_demo/test_inputs/dragon-growl-37570.wav'.\n", - "Audio file downloaded successfully and saved as '/Users/raghavdixit/Desktop/open_source/vectordb-recipes_rd/examples/imagebind_demo/test_inputs/car_audio.wav'.\n", - "/Users/raghavdixit/Desktop/open_source/vectordb-recipes_rd/.env/lib/python3.10/site-packages/torchvision/transforms/_functional_video.py:6: UserWarning: The 'torchvision.transforms._functional_video' module is deprecated since 0.12 and will be removed in the future. Please use the 'torchvision.transforms.functional' module instead.\n", - " warnings.warn(\n", - "/Users/raghavdixit/Desktop/open_source/vectordb-recipes_rd/.env/lib/python3.10/site-packages/torchvision/transforms/_transforms_video.py:22: UserWarning: The 'torchvision.transforms._transforms_video' module is deprecated since 0.12 and will be removed in the future. Please use the 'torchvision.transforms' module instead.\n", - " warnings.warn(\n", - "Running on local URL: http://127.0.0.1:7860\n", - "Running on public URL: https://9a7b06fd92e0284673.gradio.live\n", - "\n", - "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n", - "^C\n", - "Keyboard interruption in main thread... closing server.\n", - "Killing tunnel 127.0.0.1:7860 <> https://9a7b06fd92e0284673.gradio.live\n" - ] - } - ], - "source": [ - "! python3 ./app.py" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.13" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}