Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tool pytorch2torchscript #469

Merged
merged 2 commits into from
Apr 19, 2021
Merged

add tool pytorch2torchscript #469

merged 2 commits into from
Apr 19, 2021

Conversation

sshuair
Copy link
Contributor

@sshuair sshuair commented Apr 10, 2021

This PR contribute the feature that could convert the PyTorch(.pth) model to TorchScript(.pt) model. So that the MMSeg model can be used in LibTorch with C++.

This repo mmseg-libtorch show the usage and result.

It's exactly the same between the PyTorch(.pth) and TorchScript(.pt) result.

It's need Pytorch>=1.8.0.

Some examples:

  1. PSPNet - cityscapes
image PyTorch result LibTorch result
  1. DeepLabV3+ - PascalVoc

    image PyTorch result LibTorch result
  2. FCN - ADE

    image PyTorch result LibTorch result

@codecov
Copy link

codecov bot commented Apr 10, 2021

Codecov Report

Merging #469 (3908a56) into master (a897a34) will decrease coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #469      +/-   ##
==========================================
- Coverage   86.58%   86.50%   -0.08%     
==========================================
  Files          97       97              
  Lines        4964     4966       +2     
  Branches      807      806       -1     
==========================================
- Hits         4298     4296       -2     
- Misses        514      517       +3     
- Partials      152      153       +1     
Flag Coverage Δ
unittests 86.50% <ø> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmseg/apis/inference.py 63.79% <0.00%> (-2.28%) ⬇️
mmseg/ops/wrappers.py 80.76% <0.00%> (-1.99%) ⬇️
mmseg/models/segmentors/encoder_decoder.py 90.84% <0.00%> (-1.16%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a897a34...3908a56. Read the comment docs.

@sshuair
Copy link
Contributor Author

sshuair commented Apr 16, 2021

@xvjiarui Hi, any review or suggest?

@xvjiarui
Copy link
Collaborator

Sorry for the late review. Code looks good to me. Only a few comments.

@sshuair
Copy link
Contributor Author

sshuair commented Apr 17, 2021

@xvjiarui the pytorch version assert message is fixed.

And the codecov's problem does not seem to be caused by this PR.

@xvjiarui xvjiarui merged commit 8f37e55 into open-mmlab:master Apr 19, 2021
bowenroom pushed a commit to bowenroom/mmsegmentation that referenced this pull request Feb 25, 2022
* add tool pytorch2torchscript

* fix the assert message for pytorch version.
wjkim81 pushed a commit to wjkim81/mmsegmentation that referenced this pull request Dec 3, 2023
* add albu

* remove Normalize

* resolve comments

* albu to albumentation

* add an example for keymap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants