Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement common post_processing #11408

Merged
merged 3 commits into from
May 17, 2024
Merged

Conversation

MarcA711
Copy link
Contributor

This PR implements a structure to store post_processing in a common place for all detectors to avoid duplicate code and make it easier to support new models.

Steps to invoke post_processing from a detector:

class Rknn(DetectionApi):
    def __init__(self, config: RknnDetectorConfig):
        super().__init__(config)
        ...
 
    def detect_raw(self, tensor_input):
        output = inference(tensor_input)
        return self.post_process(output)

In case you want to implement your own post-processing for a model (for example to use hardware acceleration using opencl), reimplement the method like this:

def yolonas(self, output):
    if gpu_found:
        # implement hw post_processing ...
        return results
    else:
        return super().yolonas(output)

However, use this only if your implementation is significantly faster than the default implementation.

Steps to add a new model:

  • add entry to ModelTypeEnum in frigate/detector/detector_config.py
  • add model identifier to docs/docs/reference.md
  • implement a new method in frigate/detectors/detection_api.py
    • try to implement post-processing using numpy, as all platforms use this
  • call the method from post_processing in frigate/detectors/detection_api.py

Copy link

netlify bot commented May 17, 2024

Deploy Preview for frigate-docs canceled.

Name Link
🔨 Latest commit aded9c9
🔍 Latest deploy log https://app.netlify.com/sites/frigate-docs/deploys/66478707dfbe690008b8a4c0

@NickM-27 NickM-27 merged commit a70dd02 into blakeblackshear:dev May 17, 2024
10 checks passed
@MarcA711 MarcA711 deleted the postprocess branch May 24, 2024 09:51
@MarcA711 MarcA711 restored the postprocess branch May 24, 2024 09:51
@MarcA711 MarcA711 deleted the postprocess branch May 24, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants