vietanhdev / samexporter

Export Segment Anything Models to ONNX
https://pypi.org/project/samexporter/
MIT License
239 stars 29 forks source link

Where does the 684 height size comes from? #4

Open simoneorlando opened 1 year ago

simoneorlando commented 1 year ago

Not an issue. The code works perfectly for me. I saw the original code expects 1024x1024 image size. So, I was just wondering where the 684 fixed size for height comes from. Thank you

vietanhdev commented 1 year ago

@simoneorlando For ONNX model, the image ratio need to be kept to prevent shifting result. More details. 1024:684 is the fixed ratio in converted ONNX models.

dogvane commented 1 year ago

I use truck.jpg and truck_prompt.json to run onnx demo, change input size from (684,1024) to (1024,1024) not find error.

kwaegel commented 10 months ago

@vietanhdev I read through the segment-anything tickets 56 and 130, and it looks like the fixed aspect ratio was a bug in the SAM package that has been fixed in SAM PR-58.

Unfortunately, that PR was merged three days after the segment-anything v1.0 package was pushed to PyPi, so by default this will keep happening.

Cloning the SAM repo and installing it with pip install -e . instead of using the PyPi package specified in the requirements.txt file, and then re-exporting the weights using samexporter, seems to have fixed the scaling issue, and the 684 number may no longer be relevant.

(Check my work on this one. Python isn't my native language.)