Skip to content

Commit 06ca915

Browse files
committed
add min_confidence
1 parent 936cd59 commit 06ca915

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

deepstack/core.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
DEFAULT_TIMEOUT = 10 # seconds
1111
DEFAULT_IP = "localhost"
1212
DEFAULT_PORT = 80
13+
DEFAULT_MIN_CONFIDENCE = 0.45
1314

1415
## HTTP codes
1516
HTTP_OK = 200
@@ -136,17 +137,18 @@ def __init__(
136137
port: int = DEFAULT_PORT,
137138
api_key: str = DEFAULT_API_KEY,
138139
timeout: int = DEFAULT_TIMEOUT,
140+
min_confidence: float = DEFAULT_MIN_CONFIDENCE,
139141
url_detect: str = "",
140142
url_recognize: str = "",
141143
url_register: str = "",
142144
):
143-
145+
self._api_key = api_key
146+
self._timeout = timeout
147+
self._min_confidence = min_confidence
144148
self._url_base = URL_BASE_VISION.format(ip=ip, port=port)
145149
self._url_detect = self._url_base + url_detect
146150
self._url_recognize = self._url_base + url_recognize
147151
self._url_register = self._url_base + url_register
148-
self._api_key = api_key
149-
self._timeout = timeout
150152

151153
def detect(self):
152154
"""Process image_bytes and detect."""
@@ -170,14 +172,20 @@ def __init__(
170172
port: int = DEFAULT_PORT,
171173
api_key: str = DEFAULT_API_KEY,
172174
timeout: int = DEFAULT_TIMEOUT,
175+
min_confidence: float = DEFAULT_MIN_CONFIDENCE,
173176
custom_model: str = "",
174177
):
175178
if custom_model:
176179
url_detect = URL_CUSTOM.format(custom_model=custom_model)
177180
else:
178181
url_detect = URL_OBJECT_DETECTION
179182
super().__init__(
180-
ip=ip, port=port, api_key=api_key, timeout=timeout, url_detect=url_detect,
183+
ip=ip,
184+
port=port,
185+
api_key=api_key,
186+
timeout=timeout,
187+
min_confidence=min_confidence,
188+
url_detect=url_detect,
181189
)
182190

183191
def detect(self, image_bytes: bytes):
@@ -200,12 +208,14 @@ def __init__(
200208
port: int = DEFAULT_PORT,
201209
api_key: str = DEFAULT_API_KEY,
202210
timeout: int = DEFAULT_TIMEOUT,
211+
min_confidence: float = DEFAULT_MIN_CONFIDENCE,
203212
):
204213
super().__init__(
205214
ip=ip,
206215
port=port,
207216
api_key=api_key,
208217
timeout=timeout,
218+
min_confidence=min_confidence,
209219
url_recognize=URL_SCENE_RECOGNIZE,
210220
)
211221

@@ -230,12 +240,14 @@ def __init__(
230240
port: int = DEFAULT_PORT,
231241
api_key: str = DEFAULT_API_KEY,
232242
timeout: int = DEFAULT_TIMEOUT,
243+
min_confidence: float = DEFAULT_MIN_CONFIDENCE,
233244
):
234245
super().__init__(
235246
ip=ip,
236247
port=port,
237248
api_key=api_key,
238249
timeout=timeout,
250+
min_confidence=min_confidence,
239251
url_detect=URL_FACE_DETECTION,
240252
url_register=URL_FACE_REGISTER,
241253
url_recognize=URL_FACE_RECOGNIZE,

usage-object-detection.ipynb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,27 @@
355355
"predictions"
356356
]
357357
},
358+
{
359+
"cell_type": "code",
360+
"execution_count": 16,
361+
"metadata": {},
362+
"outputs": [
363+
{
364+
"data": {
365+
"text/plain": [
366+
"{'a': 'a', 'b': 'b'}"
367+
]
368+
},
369+
"execution_count": 16,
370+
"metadata": {},
371+
"output_type": "execute_result"
372+
}
373+
],
374+
"source": [
375+
"data = {'a':'a', 'b':'b'}\n",
376+
"data"
377+
]
378+
},
358379
{
359380
"cell_type": "code",
360381
"execution_count": null,

0 commit comments

Comments
 (0)