File size: 4,138 Bytes
c6a4560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
{
 "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
}