{ "cells": [ { "cell_type": "markdown", "id": "86111f81-16f5-46e5-9010-1ef9e05a1571", "metadata": { "copyright": [ "INTEL CONFIDENTIAL", "Copyright (C) 2022 Intel Corporation", "This software and the related documents are Intel copyrighted materials, and your use of them is governed by", "the express license under which they were provided to you (\"License\"). Unless the License provides otherwise,", "you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related documents", "without Intel's prior written permission.", "This software and the related documents are provided as is, with no express or implied warranties,", "other than those that are expressly stated in the License." ] }, "source": [ "# Intel® Geti™ deployment demo notebook\n", "This notebook demonstrates how to run inference for a deployed Intel® Geti™ project on your local machine. It contains the following steps:\n", "1. Load the deployment for the project from the exported `deployment` folder\n", "2. Load a sample image to run inference on\n", "3. Prepare the deployment for inference by sending the model (or models) for the project to the CPU\n", "4. Infer image\n", "5. Visualize prediction" ] }, { "cell_type": "markdown", "id": "a0ee561b-49fb-4f8b-9c7f-e4859e3fe99e", "metadata": {}, "source": [ "### Step 1: Load the deployment" ] }, { "cell_type": "code", "execution_count": null, "id": "d04d3e58-8cae-4491-86b6-fbc876fd5e4f", "metadata": {}, "outputs": [], "source": [ "from geti_sdk.deployment import Deployment\n", "\n", "deployment = Deployment.from_folder(\"../deployment\")" ] }, { "cell_type": "markdown", "id": "713de7c8-0ac4-4865-b947-98ecbc4173fb", "metadata": {}, "source": [ "### Step 2: Load the sample image" ] }, { "cell_type": "code", "execution_count": null, "id": "5c61e01f-2c88-4f0d-ae18-88610cc13bf2", "metadata": {}, "outputs": [], "source": [ "import cv2\n", "\n", "image = cv2.imread(\"../sample_image.jpg\")\n", "image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)" ] }, { "cell_type": "markdown", "id": "40da9013-46f7-488d-972d-5ceddd54a60c", "metadata": {}, "source": [ "### Step 3: Send inference model(s) to CPU" ] }, { "cell_type": "code", "execution_count": null, "id": "f6b80e6f-57fa-421a-b71f-ffbd0847c0a9", "metadata": {}, "outputs": [], "source": [ "deployment.load_inference_models(device='CPU')" ] }, { "cell_type": "markdown", "id": "6f539adc-04e7-43b4-b113-99e7ff7f6482", "metadata": {}, "source": [ "### Step 4: Infer image" ] }, { "cell_type": "code", "execution_count": null, "id": "a0e72d41-ec75-4bfe-859b-7302463b9fb6", "metadata": {}, "outputs": [], "source": [ "prediction = deployment.infer(image_rgb)" ] }, { "cell_type": "markdown", "id": "5f450bb5-29dc-4ac4-b5bb-4b02f350aacc", "metadata": {}, "source": [ "### Step 5: Visualization" ] }, { "cell_type": "code", "execution_count": null, "id": "db0dd922-36aa-4203-bc02-76c17d12d8be", "metadata": {}, "outputs": [], "source": [ "from geti_sdk.utils import show_image_with_annotation_scene\n", "\n", "show_image_with_annotation_scene(image_rgb, prediction, show_in_notebook=True)" ] }, { "cell_type": "code", "execution_count": null, "id": "a342324f-3177-4d61-bee4-40b47d0f78f8", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "celltoolbar": "Edit Metadata", "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }