PyTorch Models and Git in MATLAB Online
Create and Clone GitHub Repository
We first created a new GitHub repository with a README file. We cloned this repository in MATLAB Online, which copied all the files from the repository to a folder in our working directory. Animated Figure: Create a GitHub repository and clone it with MATLAB Online. We generated a personal access token to use in place of a password. We are going to need the token to authenticate with GitHub when pushing our new or updated files to the GitHub repository. Animated Figure: Generate personal access token.Import Model from PyTorch in MATLAB Online
Starting in MATLAB R2023b, you can import models from PyTorch in MATLAB Online. To show this functionality, we reused the code from the doc example Import Network from PyTorch and Classify Image. Once we confirmed that the code runs as expected (that is, the PyTorch model is successfully imported and the test image is correctly classified), in three quick steps we uploaded the code to our GitHub repository.- We added the live script to Source Control.
- We committed the script.
- We pushed the script to the GitHub repository.
Add MATLAB Online Button to Repository
Finally, we added an “Open in MATLAB Online” button to our GitHub repository. By clicking on the button, the GitHub repository opens directly in MATLAB Online (independently from the Git-tracked folder that we previously created). This makes it easy to share your code with your team or community. To learn more, see Open in MATLAB Online from GitHub. Animated Figure: Open code from GitHub repository with MATLAB Online.
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.