PyTorch Models and Git in MATLAB Online
The following post is from Yann Debray, Product Manager for MATLAB Online, and Sivylla Paraskevopoulou, Product Marketing Manager for AI.
Do you use MATLAB Online to create AI workflows? Do you want to write trackable and shareable code?
This blog post shows you how to (1) import models from PyTorch® using MATLAB Online, (2) use Git™ source control in MATLAB Online, and (3) open MATLAB Online directly from GitHub®. For each of the steps of the workflow, we have included a short animation to help you replicate the step.
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.
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.