1010DEFAULT_TIMEOUT = 10 # seconds
1111DEFAULT_IP = "localhost"
1212DEFAULT_PORT = 80
13+ DEFAULT_MIN_CONFIDENCE = 0.45
1314
1415## HTTP codes
1516HTTP_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 ,
0 commit comments