Я пытаюсь экспортировать свою модель Pytorch в формат ONNX, обеспечивая, чтобы размер партии оставался динамическим. Вот код, который я использую: < /p>
import torch # Import PyTorch library
# Create a dummy input tensor of shape (1, 3, 256, 256) and move it to the appropriate device
dummy_input = torch.randn(1, 3, 256, 256).to(device)
# Create dummy camera and view labels, initialized to zeros, and move them to the device
dummy_cam = torch.zeros(1, dtype=torch.long).to(device)
dummy_view = torch.zeros(1, dtype=torch.long).to(device)
# Export the model to ONNX format
torch.onnx.export(
model, # The PyTorch model to be converted
(dummy_input, dummy_cam, dummy_view), # The input tuple
"deit_transreid_veri.onnx", # The output file name
input_names=["input", "cam_label", "view_label"], # Naming the input tensors
output_names=["output"], # Naming the output tensor
dynamic_axes={ # Define dynamic batch size for inputs and outputs
'input': {0: 'batch_size'},
'cam_label': {0: 'batch_size'},
'view_label': {0: 'batch_size'},
'output': {0: 'batch_size'}
},
opset_version=13, # Specify the ONNX opset version
verbose=True, # Print detailed information during export
)
print("Model has been successfully exported to ONNX format!") # Confirmation message
Подробнее здесь: https://stackoverflow.com/questions/794 ... -generated
Когда я запускаю кодовую onnx export stop без ошибки, и не генерируется файл ONNX, не можете ли вы мне помочь? ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Невозможно передать kwargs в аргументы torch.onnx.export в Pytorch ONNX.
Anonymous » » в форуме Python - 0 Ответы
- 41 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Android Adb Stop Command Application, такая как «Force-Stop» для неуровного устройства
Anonymous » » в форуме Android - 0 Ответы
- 5 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Поставщик выполнения CUDA в ONNX допускает ошибку при объединении TensorRT с ONNX
Anonymous » » в форуме Python - 0 Ответы
- 35 Просмотры
-
Последнее сообщение Anonymous
-
-
-
«'.../src/onnx/gen_proto.py' не является командой Конана» при сборке onnx
Anonymous » » в форуме C++ - 0 Ответы
- 32 Просмотры
-
Последнее сообщение Anonymous
-