MCPcopy Create free account
hub / github.com/Vinyzu/recognizer / Detector

Class Detector

recognizer/components/detector.py:301–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299
300
301class Detector:
302 # fmt: off
303 challenge_alias = {
304 "car": "car", "cars": "car", "vehicles": "car",
305 "taxis": "taxi", "taxi": "taxi",
306 "bus": "bus", "buses": "bus",
307 "motorcycle": "motorcycle", "motorcycles": "motorcycle",
308 "bicycle": "bicycle", "bicycles": "bicycle",
309 "boats": "boat", "boat": "boat",
310 "tractors": "tractor", "tractor": "tractor",
311 "stairs": "stair", "stair": "stair",
312 "palm trees": "palm tree", "palm tree": "palm tree",
313 "fire hydrants": "fire hydrant", "a fire hydrant": "fire hydrant", "fire hydrant": "fire hydrant",
314 "parking meters": "parking meter", "parking meter": "parking meter",
315 "crosswalks": "crosswalk", "crosswalk": "crosswalk",
316 "traffic lights": "traffic light", "traffic light": "traffic light",
317 "bridges": "bridge", "bridge": "bridge",
318 "mountains or hills": "mountain", "mountain or hill": "mountain", "mountain": "mountain", "mountains": "mountain", "hills": "mountain", "hill": "mountain",
319 "chimney": "chimney", "chimneys": "chimney"
320 }
321
322 # fmt: on
323
324 def __init__(self, optimize_click_order: Optional[bool] = True) -> None:
325 """
326 Spawn a new reCognizer Detector Instance
327
328 Args:
329 optimize_click_order (bool, optional): Whether to optimize the click order with the Travelling Salesman Problem. Defaults to True.
330 """
331 self.optimize_click_order = optimize_click_order
332
333 self.detection_models: DetectionModels = detection_models
334 self.yolo_detector = YoloDetector()
335 self.clip_detector = ClipDetector()
336
337 def detect(
338 self,
339 prompt: str,
340 images: Union[
341 Path,
342 Union[PathLike[str], str],
343 bytes,
344 Sequence[Path],
345 Sequence[Union[PathLike[str], str]],
346 Sequence[bytes],
347 ],
348 area_captcha: Optional[bool] = None,
349 ) -> Tuple[List[bool], List[Tuple[int, int]]]:
350 """
351 Solves a reCaptcha Task with the given prompt and images.
352
353 Args:
354 prompt (str): The prompt name/sentence of the captcha (e.g. "Select all images with crosswalks" / "crosswalk").
355 images (Path | PathLike | bytes | Sequence[Path] | Sequence[PathLike] | Sequence[bytes]): The Image(s) to reCognize.
356 area_captcha (bool, optional): Whether the Captcha Task is an area-captcha.
357
358 Returns:

Callers 4

detectorFunction · 0.90
demo_detect.pyFile · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by 1

detectorFunction · 0.72