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

Added yolov8engine.py for TensorRT-quantized YOLOv8 models #1046

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

alsozatch
Copy link

Model file to allow for SAHI inference on yolov8 TensorRT quantized .engine models. Used exactly the same as the base Yolov8 model, except

  1. Requires a config_path variable to a .json file with below structure.
  2. Can't use the config file fields as extra fields in **kwargs like the base yolov8.py uses config_path.

Here's a function to grab the config file information from the .pt file that you quantized from initially.
Still need to manually put in imgsz and half flag equivalent to the imgsz and half parameters you use to quantize it.

def record_metadata_json(self, json_path, imgsz, half):
        task = self.model.task
        names = self.model.names
        names_list = list(names.values())

        metadata = {
            "task": task,
            "names": names_list,
            "imgsz": imgsz,
            "half": half,
        }
        
        with open(json_path, 'w') as json_file:
            json.dump(metadata, json_file, indent=4)

@fcakyon
Copy link
Collaborator

fcakyon commented Jun 2, 2024

@alsozatch, thanks for your contribution!

Can you please check the errors in the tests and try to fix them?

@alsozatch
Copy link
Author

alsozatch commented Jun 3, 2024

@alsozatch, thanks for your contribution!

Can you please check the errors in the tests and try to fix them?

It looks like you are using 'isort' and 'black' to enforce some order for imports. I've not used these packages so I'm not sure what I'm looking at. Is the required import format specified somewhere?

@fcakyon
Copy link
Collaborator

fcakyon commented Jun 7, 2024

@alsozatch you can check this section, formatting is very easy and automated by a script 👍🏻 https://github.com/obss/sahi?tab=readme-ov-file#contributing

@lucasbarrez
Copy link

Hey @alsozatch, @fcakyon,

Will the integration and maintenance of the use of the engine format be available? Or should we implement it on our side?

Thx.

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.

3 participants