feat: add instructions to export to onnx

This commit is contained in:
Laurent Fainsin 2023-04-05 22:10:29 +02:00
parent 780a5688a0
commit 6a70a46042
2 changed files with 12 additions and 1 deletions

2
.vscode/launch.json vendored
View file

@ -17,7 +17,7 @@
// "--ckpt_path", // "--ckpt_path",
// "${workspaceFolder}/lightning_logs/version_264/checkpoints/epoch=9-st&ep=1000.ckpt", // "${workspaceFolder}/lightning_logs/version_264/checkpoints/epoch=9-st&ep=1000.ckpt",
"--data.num_workers", "--data.num_workers",
"0", "1",
"--trainer.benchmark", "--trainer.benchmark",
"false", "false",
"--trainer.num_sanity_val_steps", "--trainer.num_sanity_val_steps",

View file

@ -28,6 +28,17 @@ Start inference on images:
python src/main.py predict --ckpt_path <path_to_checkpoint> python src/main.py predict --ckpt_path <path_to_checkpoint>
``` ```
Quick and dirty way to export to `.onnx`:
```python
>>> from src.module import DETR
>>> checkpoint = "<path_to_checkpoint>"
>>> model = DETR.load_from_checkpoint(checkpoint)
>>> model.net.save_pretrained("hugginface_checkpoint")
```
```bash
python -m transformers.onnx --model=hugginface_checkpoint onnx_export/
```
## License ## License
Distributed under the [MIT](https://choosealicense.com/licenses/mit/) license. \ Distributed under the [MIT](https://choosealicense.com/licenses/mit/) license. \