-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert detectors to factory pattern, ability to set different model …
…for each detector (#4635) * refactor detectors * move create_detector and DetectorTypeEnum * fixed code formatting * add detector model config models * fix detector unit tests * adjust SharedMemory size to largest detector model shape * fix detector model config defaults * enable auto-discovery of detectors * simplify config * simplify config changes further * update detectors docs; detect detector configs dynamic * add suggested changes * remove custom detector doc * fix grammar, adjust device defaults
- Loading branch information
Showing
15 changed files
with
402 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
|
||
from .detection_api import DetectionApi | ||
from .detector_config import ( | ||
PixelFormatEnum, | ||
InputTensorEnum, | ||
ModelConfig, | ||
) | ||
from .detector_types import DetectorTypeEnum, api_types, DetectorConfig | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def create_detector(detector_config): | ||
if detector_config.type == DetectorTypeEnum.cpu: | ||
logger.warning( | ||
"CPU detectors are not recommended and should only be used for testing or for trial purposes." | ||
) | ||
|
||
api = api_types.get(detector_config.type) | ||
if not api: | ||
raise ValueError(detector_config.type) | ||
return api(detector_config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.