|
271 | 271 | " return base64.b64encode(arr_bytes.getvalue()).decode(\"utf-8\")\n", |
272 | 272 | "\n", |
273 | 273 | "\n", |
274 | | - "# @markdown **(Optional)** Override the endpoint id.\n", |
275 | | - "# @markdown *Note: If kept empty uses the recently deployed endpoint.*\n", |
276 | | - "# @markdown *Note: Make sure to use the endpoid id from the previous cell output*\n", |
277 | | - "# @markdown * (Not the endpoint name used above)*\n", |
278 | | - "ENDPOINT_ID = \"\" # @param { 'type': 'string' }\n", |
279 | | - "use_dedicated_endpoint = True # @param { 'type' : 'boolean' }\n", |
280 | | - "\n", |
281 | | - "if ENDPOINT_ID:\n", |
282 | | - " endpoint = aiplatform.Endpoint(ENDPOINT_ID)\n", |
283 | | - "\n", |
284 | 274 | "# Download sample images\n", |
285 | 275 | "!wget -O harbor.jpg https://mrsg.aegean.gr/images/uploads/it2zi0eidej4ql33llj.jpg\n", |
286 | 276 | "!wget -O palace.jpeg https://www.spaceintelreport.com/wp-content/uploads/2021/05/Pleiades-NEO-US-Capitol-30cm.jpeg\n", |
287 | 277 | "harbor_img = Image.open(\"harbor.jpg\")\n", |
288 | 278 | "palace_img = Image.open(\"palace.jpeg\")" |
289 | 279 | ] |
290 | 280 | }, |
| 281 | + { |
| 282 | + "cell_type": "code", |
| 283 | + "execution_count": null, |
| 284 | + "metadata": { |
| 285 | + "cellView": "form", |
| 286 | + "id": "Jvdv-GLjKaWN" |
| 287 | + }, |
| 288 | + "outputs": [], |
| 289 | + "source": [ |
| 290 | + "# @markdown **(Optional)** Override the endpoint (use a different one).\n", |
| 291 | + "# @markdown This is useful if you want to use a test a previously deployed model.\n", |
| 292 | + "# @markdown otherwise the inference samples will use the recently deployed model.\n", |
| 293 | + "ENDPOINT_ID = \"\" # @param { 'type': 'string' }\n", |
| 294 | + "use_dedicated_endpoint = True # @param { 'type' : 'boolean' }\n", |
| 295 | + "\n", |
| 296 | + "if ENDPOINT_ID:\n", |
| 297 | + " endpoint = aiplatform.Endpoint(ENDPOINT_ID)" |
| 298 | + ] |
| 299 | + }, |
291 | 300 | { |
292 | 301 | "cell_type": "code", |
293 | 302 | "execution_count": null, |
|
309 | 318 | " parameters={\"batch_size\": 2},\n", |
310 | 319 | " use_dedicated_endpoint=use_dedicated_endpoint,\n", |
311 | 320 | ")\n", |
| 321 | + "print(\"Image encoder result, should contain 2 instances with embeddings.\")\n", |
312 | 322 | "print(result)\n", |
313 | 323 | "\n", |
314 | 324 | "# Call text encoder with multiple input instances\n", |
|
322 | 332 | " parameters={\"batch_size\": 2},\n", |
323 | 333 | " use_dedicated_endpoint=use_dedicated_endpoint,\n", |
324 | 334 | ")\n", |
| 335 | + "print(\"Text encoder result, should contain 2 instances with embeddings.\")\n", |
325 | 336 | "print(result)\n", |
326 | 337 | "\n", |
327 | 338 | "# Call the zero-shot classification on the harbor & palace image, returns\n", |
|
335 | 346 | " parameters={\"batch_size\": 2},\n", |
336 | 347 | " use_dedicated_endpoint=use_dedicated_endpoint,\n", |
337 | 348 | ")\n", |
| 349 | + "print(\"Zero-shot classification result including similarity scores.\")\n", |
338 | 350 | "print(result)" |
339 | 351 | ] |
340 | 352 | }, |
|
361 | 373 | " parameters={\"batch_size\": 1},\n", |
362 | 374 | " use_dedicated_endpoint=use_dedicated_endpoint,\n", |
363 | 375 | ")\n", |
| 376 | + "print(\"Image detection result, should contain 1 instance with object-level embeddings.\")\n", |
364 | 377 | "print(result)\n", |
365 | 378 | "\n", |
366 | 379 | "# Call text encoder with multiple texts, returns text embeddings for each input.\n", |
|
374 | 387 | " parameters={\"batch_size\": 4},\n", |
375 | 388 | " use_dedicated_endpoint=use_dedicated_endpoint,\n", |
376 | 389 | ")\n", |
| 390 | + "print(\"Text encoder result, should contain 4 instances with text embeddings.\")\n", |
377 | 391 | "print(result)\n", |
378 | 392 | "\n", |
379 | 393 | "# Call the Open Vocabulary Detection mode with image/texts pairs, returns\n", |
|
393 | 407 | " },\n", |
394 | 408 | " use_dedicated_endpoint=use_dedicated_endpoint,\n", |
395 | 409 | ")\n", |
| 410 | + "print(\"Object detection result, including detection results with 100 objects each.\")\n", |
396 | 411 | "print(result)" |
397 | 412 | ] |
398 | 413 | }, |
|
0 commit comments