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

Why does ptq quantization yield different results? #3436

Closed
lucy3589 opened this issue Nov 8, 2023 · 4 comments
Closed

Why does ptq quantization yield different results? #3436

lucy3589 opened this issue Nov 8, 2023 · 4 comments
Assignees
Labels
triaged Issue has been triaged by maintainers

Comments

@lucy3589
Copy link

lucy3589 commented Nov 8, 2023

Same onnx, same check set, same code. Why does fp32_onnx change to trt-int8 every time? Is the mAP measured differently on the verification set?

I use samples/python/efficientdet/build_engine.py. and modify image_bathcer.py-resize_pad .

def resize_pad(image, pad_color=(114,114,114)):
            width, height = image.size
            width_scale = width / self.width
            height_scale = height / self.height
            scale = 1.0 / max(width_scale, height_scale)
            _w,_h=round(width * scale), round(height * scale)
            image = image.resize((_w,_h), resample=Image.BILINEAR)

            dw, dh = self.width - _w, self.height-_h
            dw /= 2  # divide padding into 2 sides
            dh /= 2
            top, bottom = int(round(dh - 0.1)), int(round(dh + 0.1))
            left, right = int(round(dw - 0.1)), int(round(dw + 0.1))

            pad = Image.new("RGB", (self.width, self.height))
            pad.paste(pad_color, [0, 0, self.width, self.height])
            pad.paste(image,(left, top))
            # pad.show()
            return pad, scale

shuffle use random.seed(47) trt.IInt8EntropyCalibrator2

python build_engine.py --onnx yolov8n-seg.onnx --engine yolov8n-seg-int8.engine --precision int8 --calib_input datasets\coco-seg\images\sample --calib_cache calibrationall8.cache

@zerollzeng
Copy link
Collaborator

Sorry I don't get your problem, do you mean every time you do calibration, you get slightly different calibrationall8.cache?

@zerollzeng zerollzeng self-assigned this Nov 12, 2023
@zerollzeng zerollzeng added the triaged Issue has been triaged by maintainers label Nov 12, 2023
@lucy3589
Copy link
Author

Sorry I don't get your problem, do you mean every time you do calibration, you get slightly different calibrationall8.cache?

Yes. That's what you said

@zerollzeng
Copy link
Collaborator

I think it's expected. @ttyio for more information.

@ttyio
Copy link
Collaborator

ttyio commented Apr 16, 2024

closing since no activity for more than 3 weeks, thanks all

@ttyio ttyio closed this as completed Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

3 participants