-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ENH]: Add install dependencies section in multimodal_retrieval.ipynb #4491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,20 +11,37 @@ | |||||
"This notebook shows an example of how to create and query a collection with both text and images, using Chroma's built-in features. " | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"metadata": {}, | ||||||
"source": [ | ||||||
"## Install Dependencies\n", | ||||||
"Before we start, let's install some dependencies first to ensure that the example below works." | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "code", | ||||||
"execution_count": null, | ||||||
"metadata": {}, | ||||||
"outputs": [], | ||||||
"source": [ | ||||||
"%pip install datasets chromadb open-clip-torch" | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"metadata": {}, | ||||||
"source": [ | ||||||
"## Dataset\n", | ||||||
"\n", | ||||||
"We us a small subset of the [coco object detection dataset](https://huggingface.co/datasets/detection-datasets/coco), hosted on HuggingFace. \n", | ||||||
"We use a small subset of the [coco object detection dataset](https://huggingface.co/datasets/detection-datasets/coco), hosted on HuggingFace. \n", | ||||||
"\n", | ||||||
"We download a small fraction of all the images in the dataset locally, and use it to create a multimodal collection." | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "code", | ||||||
"execution_count": 1, | ||||||
"execution_count": null, | ||||||
"metadata": {}, | ||||||
"outputs": [ | ||||||
{ | ||||||
|
@@ -334,7 +351,7 @@ | |||||
}, | ||||||
{ | ||||||
"cell_type": "code", | ||||||
"execution_count": 9, | ||||||
"execution_count": null, | ||||||
"metadata": {}, | ||||||
"outputs": [ | ||||||
{ | ||||||
|
@@ -414,7 +431,7 @@ | |||||
"\n", | ||||||
"print(\"Results\")\n", | ||||||
"retrieved = collection.query(query_images=[query_image], include=['data'], n_results=5)\n", | ||||||
"for img in retrieved['data'][0][1:]:\n", | ||||||
"for img in retrieved['data'][0][:]:\n", | ||||||
" plt.imshow(img)\n", | ||||||
" plt.axis(\"off\")\n", | ||||||
" plt.show()" | ||||||
|
@@ -429,7 +446,7 @@ | |||||
}, | ||||||
{ | ||||||
"cell_type": "code", | ||||||
"execution_count": 10, | ||||||
"execution_count": null, | ||||||
"metadata": {}, | ||||||
"outputs": [ | ||||||
{ | ||||||
|
@@ -477,7 +494,7 @@ | |||||
"query_uri = image_uris[1]\n", | ||||||
"\n", | ||||||
"query_result = collection.query(query_uris=query_uri, include=['data'], n_results=5)\n", | ||||||
"for img in query_result['data'][0][1:]:\n", | ||||||
"for img in query_result['data'][0][:]:\n", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [BestPractice] Same issue here - this loop now includes the query image in the display results. Unless this is intentional, you should keep the original slicing to exclude the query image:
Suggested change
⚡ Committable suggestion Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. |
||||||
" plt.imshow(img)\n", | ||||||
" plt.axis(\"off\")\n", | ||||||
" plt.show()" | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BestPractice]
In both result loops, you're now including the query image itself in the display loop by using
[:]
instead of[1:]
. This means the first displayed image will be the query image itself, which may be redundant and confusing to users.Consider keeping the original slicing to exclude the query image from results:
⚡ Committable suggestion
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.