10
10
DEFAULT_TIMEOUT = 10 # seconds
11
11
DEFAULT_IP = "localhost"
12
12
DEFAULT_PORT = 80
13
+ DEFAULT_MIN_CONFIDENCE = 0.45
13
14
14
15
## HTTP codes
15
16
HTTP_OK = 200
@@ -136,17 +137,18 @@ def __init__(
136
137
port : int = DEFAULT_PORT ,
137
138
api_key : str = DEFAULT_API_KEY ,
138
139
timeout : int = DEFAULT_TIMEOUT ,
140
+ min_confidence : float = DEFAULT_MIN_CONFIDENCE ,
139
141
url_detect : str = "" ,
140
142
url_recognize : str = "" ,
141
143
url_register : str = "" ,
142
144
):
143
-
145
+ self ._api_key = api_key
146
+ self ._timeout = timeout
147
+ self ._min_confidence = min_confidence
144
148
self ._url_base = URL_BASE_VISION .format (ip = ip , port = port )
145
149
self ._url_detect = self ._url_base + url_detect
146
150
self ._url_recognize = self ._url_base + url_recognize
147
151
self ._url_register = self ._url_base + url_register
148
- self ._api_key = api_key
149
- self ._timeout = timeout
150
152
151
153
def detect (self ):
152
154
"""Process image_bytes and detect."""
@@ -170,14 +172,20 @@ def __init__(
170
172
port : int = DEFAULT_PORT ,
171
173
api_key : str = DEFAULT_API_KEY ,
172
174
timeout : int = DEFAULT_TIMEOUT ,
175
+ min_confidence : float = DEFAULT_MIN_CONFIDENCE ,
173
176
custom_model : str = "" ,
174
177
):
175
178
if custom_model :
176
179
url_detect = URL_CUSTOM .format (custom_model = custom_model )
177
180
else :
178
181
url_detect = URL_OBJECT_DETECTION
179
182
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 ,
181
189
)
182
190
183
191
def detect (self , image_bytes : bytes ):
@@ -200,12 +208,14 @@ def __init__(
200
208
port : int = DEFAULT_PORT ,
201
209
api_key : str = DEFAULT_API_KEY ,
202
210
timeout : int = DEFAULT_TIMEOUT ,
211
+ min_confidence : float = DEFAULT_MIN_CONFIDENCE ,
203
212
):
204
213
super ().__init__ (
205
214
ip = ip ,
206
215
port = port ,
207
216
api_key = api_key ,
208
217
timeout = timeout ,
218
+ min_confidence = min_confidence ,
209
219
url_recognize = URL_SCENE_RECOGNIZE ,
210
220
)
211
221
@@ -230,12 +240,14 @@ def __init__(
230
240
port : int = DEFAULT_PORT ,
231
241
api_key : str = DEFAULT_API_KEY ,
232
242
timeout : int = DEFAULT_TIMEOUT ,
243
+ min_confidence : float = DEFAULT_MIN_CONFIDENCE ,
233
244
):
234
245
super ().__init__ (
235
246
ip = ip ,
236
247
port = port ,
237
248
api_key = api_key ,
238
249
timeout = timeout ,
250
+ min_confidence = min_confidence ,
239
251
url_detect = URL_FACE_DETECTION ,
240
252
url_register = URL_FACE_REGISTER ,
241
253
url_recognize = URL_FACE_RECOGNIZE ,
0 commit comments