Skip to content

Commit

Permalink
Attach libtorch inference results (#138)
Browse files Browse the repository at this point in the history
* Attach libtorch inference results

* Update README.md
  • Loading branch information
zhiqwang authored Jul 14, 2021
1 parent 5395621 commit 90e301f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ torch.save(model.state_dict(), 'yolov5s_updated.pt')

### Inference on `LibTorch` backend 🚀

We provide a [notebook](notebooks/inference-pytorch-export-libtorch.ipynb) to demonstrate how the model is transformed into `torchscript`. And we provide an [C++ example](./deployment) of how to infer with the transformed `torchscript` model. For details see the [GitHub Actions](.github/workflows/ci_test.yml).
We provide a [notebook](notebooks/inference-pytorch-export-libtorch.ipynb) to demonstrate how the model is transformed into `torchscript`. And we provide an [C++ example](./deployment/libtorch) of how to infer with the transformed `torchscript` model. For details see the [GitHub Actions](.github/workflows/ci_test.yml).

## 🎨 Model Graph Visualization

Expand All @@ -120,4 +120,4 @@ Now, `yolort` can draw the model graph directly, checkout our [model-graph-visua

## 🤗 Contributing

We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us. *BTW, leave a 🌟 if you liked it, this means a lot to us, and this is the easiest way to support us* :)
We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us. *BTW, leave a 🌟 if you liked it, and this is the easiest way to support us* :)
6 changes: 4 additions & 2 deletions deployment/libtorch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ int main(int argc, char* argv[]) {
// It should be known that it takes longer time at first time
std::cout << ">>> Inference takes : " << duration.count() << " ms" << std::endl;

auto detections = output.toTuple()->elements()[1];
std::cout << ">>> OKey, detections: " << detections << std::endl;
auto detections = output.toTuple()->elements().at(1).toList().get(0).toGenericDict();
std::cout << ">>> detections labels: " << detections.at("labels") << std::endl;
std::cout << ">>> detections boxes: " << detections.at("boxes") << std::endl;
std::cout << ">>> detections scores: " << detections.at("scores") << std::endl;

return 0;
}

0 comments on commit 90e301f

Please sign in to comment.