Skip to content

Commit

Permalink
Multimodal Update cohere-embed.ipynb (#3425)
Browse files Browse the repository at this point in the history
* Multimodal Update cohere-embed.ipynb

* Reformatted
  • Loading branch information
shubhirajMsft authored Oct 23, 2024
1 parent b20cb65 commit d6a723c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions sdk/python/foundation-models/cohere/cohere-embed.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,35 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For image inputs you can try:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import base64\n",
"\n",
"# Open the image file in binary mode\n",
"with open(\"<Path to Image>\", \"rb\") as image_file:\n",
" # Read the image data\n",
" image_data = image_file.read()\n",
"\n",
" # Encode the image data to base64\n",
" base64_encoded_data = base64.b64encode(image_data)\n",
"\n",
" # Convert the base64 bytes to a string\n",
" base64_string = base64_encoded_data.decode(\"utf-8\")\n",
"\n",
"co.embed(images=[base64_string], input_type=\"image\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit d6a723c

Please sign in to comment.