|
15 | 15 | "source": [
|
16 | 16 | "import deepstack.core as ds\n",
|
17 | 17 | "from PIL import Image\n",
|
| 18 | + "import pprint\n", |
18 | 19 | "import matplotlib.pyplot as plt\n",
|
19 | 20 | "%matplotlib inline"
|
20 | 21 | ]
|
21 | 22 | },
|
22 | 23 | {
|
23 | 24 | "cell_type": "code",
|
24 |
| - "execution_count": 2, |
| 25 | + "execution_count": 6, |
25 | 26 | "metadata": {},
|
26 | 27 | "outputs": [],
|
27 | 28 | "source": [
|
28 | 29 | "IP_ADDRESS = 'localhost'\n",
|
29 |
| - "PORT = '5000'" |
| 30 | + "PORT = '5000'\n", |
| 31 | + "API_KEY = \"Mysecretkey\"\n", |
| 32 | + "# API_KEY = \"BadKey\"\n", |
| 33 | + "TIMEOUT = 8" |
30 | 34 | ]
|
31 | 35 | },
|
32 | 36 | {
|
33 | 37 | "cell_type": "code",
|
34 |
| - "execution_count": 3, |
| 38 | + "execution_count": 7, |
35 | 39 | "metadata": {},
|
36 | 40 | "outputs": [],
|
37 | 41 | "source": [
|
38 |
| - "dsobject = ds.DeepstackObject(IP_ADDRESS, PORT)" |
| 42 | + "dsobject = ds.DeepstackObject(IP_ADDRESS, PORT, API_KEY, TIMEOUT)" |
39 | 43 | ]
|
40 | 44 | },
|
41 | 45 | {
|
42 | 46 | "cell_type": "code",
|
43 |
| - "execution_count": 4, |
| 47 | + "execution_count": 8, |
44 | 48 | "metadata": {},
|
45 | 49 | "outputs": [
|
46 | 50 | {
|
|
71 | 75 | },
|
72 | 76 | {
|
73 | 77 | "cell_type": "code",
|
74 |
| - "execution_count": 5, |
| 78 | + "execution_count": 9, |
75 | 79 | "metadata": {},
|
76 | 80 | "outputs": [
|
77 | 81 | {
|
78 | 82 | "name": "stdout",
|
79 | 83 | "output_type": "stream",
|
80 | 84 | "text": [
|
81 |
| - "CPU times: user 7.72 ms, sys: 6.6 ms, total: 14.3 ms\n", |
82 |
| - "Wall time: 7.63 s\n" |
| 85 | + "[{'confidence': 0.9998661, 'label': 'person', 'y_min': 0, 'x_min': 258, 'y_max': 676, 'x_max': 485}, {'confidence': 0.9996547, 'label': 'person', 'y_min': 0, 'x_min': 405, 'y_max': 652, 'x_max': 639}, {'confidence': 0.99745613, 'label': 'dog', 'y_min': 311, 'x_min': 624, 'y_max': 591, 'x_max': 825}]\n" |
83 | 86 | ]
|
84 | 87 | }
|
85 | 88 | ],
|
86 | 89 | "source": [
|
87 |
| - "%%time\n", |
88 |
| - "dsobject.process_file(image_path)" |
| 90 | + "#%%time\n", |
| 91 | + "try:\n", |
| 92 | + " dsobject.process_file(image_path)\n", |
| 93 | + " print(dsobject.predictions)\n", |
| 94 | + "except ds.DeepstackException as exc:\n", |
| 95 | + " print(exc)" |
89 | 96 | ]
|
90 | 97 | },
|
91 | 98 | {
|
|
97 | 104 | },
|
98 | 105 | {
|
99 | 106 | "cell_type": "code",
|
100 |
| - "execution_count": 6, |
| 107 | + "execution_count": 10, |
101 | 108 | "metadata": {},
|
102 | 109 | "outputs": [
|
103 | 110 | {
|
|
123 | 130 | " 'x_max': 825}]"
|
124 | 131 | ]
|
125 | 132 | },
|
126 |
| - "execution_count": 6, |
| 133 | + "execution_count": 10, |
127 | 134 | "metadata": {},
|
128 | 135 | "output_type": "execute_result"
|
129 | 136 | }
|
|
142 | 149 | },
|
143 | 150 | {
|
144 | 151 | "cell_type": "code",
|
145 |
| - "execution_count": 20, |
| 152 | + "execution_count": 11, |
146 | 153 | "metadata": {},
|
147 | 154 | "outputs": [],
|
148 | 155 | "source": [
|
|
158 | 165 | },
|
159 | 166 | {
|
160 | 167 | "cell_type": "code",
|
161 |
| - "execution_count": 10, |
| 168 | + "execution_count": 12, |
162 | 169 | "metadata": {},
|
163 | 170 | "outputs": [
|
164 | 171 | {
|
|
167 | 174 | "{'dog', 'person'}"
|
168 | 175 | ]
|
169 | 176 | },
|
170 |
| - "execution_count": 10, |
| 177 | + "execution_count": 12, |
171 | 178 | "metadata": {},
|
172 | 179 | "output_type": "execute_result"
|
173 | 180 | }
|
|
185 | 192 | },
|
186 | 193 | {
|
187 | 194 | "cell_type": "code",
|
188 |
| - "execution_count": 11, |
| 195 | + "execution_count": 13, |
189 | 196 | "metadata": {},
|
190 | 197 | "outputs": [
|
191 | 198 | {
|
192 | 199 | "data": {
|
193 | 200 | "text/plain": [
|
194 |
| - "{'dog': 1, 'person': 2}" |
| 201 | + "{'person': 2, 'dog': 1}" |
195 | 202 | ]
|
196 | 203 | },
|
197 |
| - "execution_count": 11, |
| 204 | + "execution_count": 13, |
198 | 205 | "metadata": {},
|
199 | 206 | "output_type": "execute_result"
|
200 | 207 | }
|
|
212 | 219 | },
|
213 | 220 | {
|
214 | 221 | "cell_type": "code",
|
215 |
| - "execution_count": 16, |
| 222 | + "execution_count": 14, |
216 | 223 | "metadata": {},
|
217 | 224 | "outputs": [
|
218 | 225 | {
|
|
221 | 228 | "[0.9998661, 0.9996547]"
|
222 | 229 | ]
|
223 | 230 | },
|
224 |
| - "execution_count": 16, |
| 231 | + "execution_count": 14, |
225 | 232 | "metadata": {},
|
226 | 233 | "output_type": "execute_result"
|
227 | 234 | }
|
|
240 | 247 | },
|
241 | 248 | {
|
242 | 249 | "cell_type": "code",
|
243 |
| - "execution_count": 19, |
| 250 | + "execution_count": 15, |
244 | 251 | "metadata": {},
|
245 | 252 | "outputs": [
|
246 | 253 | {
|
247 |
| - "data": { |
248 |
| - "text/plain": [ |
249 |
| - "[0.9998661]" |
250 |
| - ] |
251 |
| - }, |
252 |
| - "execution_count": 19, |
253 |
| - "metadata": {}, |
254 |
| - "output_type": "execute_result" |
| 254 | + "name": "stdout", |
| 255 | + "output_type": "stream", |
| 256 | + "text": [ |
| 257 | + "1\n" |
| 258 | + ] |
255 | 259 | }
|
256 | 260 | ],
|
257 | 261 | "source": [
|
258 | 262 | "CONFIDENCE_THRESHOLD = 0.9997\n",
|
259 |
| - "ds.get_confidences_above_threshold(confidences, CONFIDENCE_THRESHOLD)" |
| 263 | + "print(len(ds.get_confidences_above_threshold(confidences, CONFIDENCE_THRESHOLD)))" |
260 | 264 | ]
|
261 | 265 | },
|
262 | 266 | {
|
|
0 commit comments