From the course: Advanced RAG Applications with Vector Databases
Demo: Storing image vectors
- [Instructor] The start of this video should be reminiscent of what we did in our text RAG chapter. We have three imports from langchain to cover, Document, FAISS, and OpenCLIPembeddings. The other two imports that we have are glob for dealing with multiple file paths, and base64 so we can convert our image into a base64 string for our LLM later. In our next code block, we start by creating an empty list to hold our documents. Then we define a function that gets our imager coding to prepare for CLIPembeddings. The encode image function takes a file path, opens the path, reads it as bytes and returns a UTF encoded string of the file. Then we loop through each of the paths to the images and create a document from each of the images. The document contains the encoded image and the metadata for the document contains the image path. To wrap things up, we store that into a FAISS vector database using the OpenCLIPembeddings as our embedding function.