You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @guschmue, can you share the command used with the sam exporter tool to get this onnx file?
p.s. : I tried exporting the vit_b version with the sam exporter tool and got a larger onnx file (360 MB compared with yours 180 MB) that runs slower in browser with webgpu. Did you convert the model weights to mixed precision/ half precision before exporting it with sam_exporter?
Thank you
The text was updated successfully, but these errors were encountered:
@flores-o I think you can see by the netron that there is an upcast layer in the file.
import torch
import torchvision.models as models
# Load a pre-trained model
model = models.resnet18(pretrained=True)
# Convert the model to half-precision (FP16)
model = model.half()
# Quantize the model parameters to FP16
quantized_model = torch.quantization.quantize_dynamic(
model, {torch.nn.Linear}, dtype=torch.float16
)
# Export the quantized model to ONNX format
torch.onnx.export(
quantized_model,
torch.randn(1, 3, 224, 224).half(), # Input shape
"quantized_resnet.onnx",
input_names=["input"],
output_names=["output"],
opset_version=11,
example_outputs=torch.randn(1, 1000).half() # Provide example outputs for dynamic axes
)
onnxruntime-inference-examples/js/segment-anything/index.js
Line 21 in 8fcc97e
Hi @guschmue, can you share the command used with the sam exporter tool to get this onnx file?
p.s. : I tried exporting the vit_b version with the sam exporter tool and got a larger onnx file (360 MB compared with yours 180 MB) that runs slower in browser with webgpu. Did you convert the model weights to mixed precision/ half precision before exporting it with sam_exporter?
Thank you
The text was updated successfully, but these errors were encountered: