Skip to content

Commit

Permalink
improve response formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vishal-dharm committed Nov 30, 2024
1 parent c6104c6 commit c1878df
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions site/en/gemini-api/docs/vision.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
"\n",
"# Retrieve two images\n",
"image_path_1 = \"https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/Palace_of_Westminster_from_the_dome_on_Methodist_Central_Hall.jpg/2560px-Palace_of_Westminster_from_the_dome_on_Methodist_Central_Hall.jpg\"\n",
"image_path_2 = \"https://storage.googleapis.com/generativeai-downloads/images/jetpack.jpg\" # Replace with the actual path to your second image\n",
"image_path_2 = \"https://storage.googleapis.com/generativeai-downloads/images/jetpack.jpg\"\n",
"\n",
"image_1 = httpx.get(image_path_1)\n",
"image_2 = httpx.get(image_path_2)\n",
Expand All @@ -287,7 +287,7 @@
"{'mime_type':'image/jpeg', 'data': base64.b64encode(image_1.content).decode('utf-8')},\n",
"{'mime_type':'image/jpeg', 'data': base64.b64encode(image_2.content).decode('utf-8')}, prompt])\n",
"\n",
"Markdown(\">\" + response.text)"
"Markdown(response.text)"
]
},
{
Expand Down Expand Up @@ -339,7 +339,7 @@
"\n",
"response = model.generate_content([sample_file_2, sample_file_3, prompt])\n",
"\n",
"Markdown(\">\" + response.text)"
"Markdown(response.text)"
]
},
{
Expand Down Expand Up @@ -381,6 +381,15 @@
"Upload the image using [`media.upload`](https://ai.google.dev/api/rest/v1beta/media/upload) and print the URI, which is used as a reference in Gemini API calls."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!curl -o jetpack.jpg https://storage.googleapis.com/generativeai-downloads/images/jetpack.jpg"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -464,7 +473,7 @@
"# Prompt the model with text and the previously uploaded image.\n",
"response = model.generate_content([sample_file, \"Describe how this product might be manufactured.\"])\n",
"\n",
"Markdown(\">\" + response.text)"
"Markdown(response.text)"
]
},
{
Expand Down Expand Up @@ -502,7 +511,7 @@
"prompt = \"Return a bounding box for each of the objects in this image in [ymin, xmin, ymax, xmax] format.\"\n",
"response = model.generate_content([sample_file_2, prompt])\n",
"\n",
"Markdown(\">\" + response.text)"
"Markdown(response.text)"
]
},
{
Expand Down

0 comments on commit c1878df

Please sign in to comment.