Creates MATLAB interfaces to Python/PyTorch computer vision models from GitHub repos or pip packages using MPyReq. For segmentation, depth estimation, object detection, image generation, super-resolution, pose estimation, optical flow, and salient object detection.
Ships in image-processing-and-computer-vision. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Build a MATLAB interface to a Python/PyTorch model repository using the MPyReq framework.
Before generating any demo script, verify that MPyReq is available. Run which MPyReq via the MATLAB MCP server (if available) or ask the user to confirm.
.mltbx file in MATLAB (double-click), which installs it as a MATLAB Add-On automatically, orMPyReq.m to the MATLAB path:
addpath("/path/to/mpyreq");
savepath; % persist across sessions
which MPyReq in MATLAB — it should return the path to MPyReq.m.Do not proceed with demo generation until MPyReq is confirmed on the path.
Ask the user for:
Fetch and analyze the GitHub repository to determine:
setup.py, setup.cfg, pyproject.toml, or README for the required Python version. Default to "3.12" if not specified. Use "3.11" if the project needs older compatibility.torch.hub.load(): only need torch and torchvision as pip packages (model downloads automatically)MPyReq.pipPackage()MPyReq.gitrepo() + MPyReq.requirementTextFile() if a requirements.txt existspip install git+<url>: use MPyReq.pipPackage("git+<url>", Name="<ProjectName>")torch, torchvision, etc.)torch.hub.load() — weights download automatically, no MPyReq.weights() neededMPyReq.weights() with the checkpoint URL.from_pretrained() — weights download automatically via the libraryCreate a MATLAB .m file that sets up the Python environment. Follow these patterns from the demo files:
Every generated script MUST begin with MPyReq.setInstallFolder(). This tells MPyReq where to download Python, packages, and model weights. Without this, MPyReq will show a GUI dialog which blocks non-interactive execution. Also include MPyReq.autoAcceptDownloadPrompts(true) to avoid interactive confirmation prompts.
% Set installation folder (SSD recommended, ~15+ GB free space)
% Change this path to a suitable location on your machine
MPyReq.setInstallFolder(fullfile(tempdir, "MPyReq"));
MPyReq.autoAcceptDownloadPrompts(true);
MPyReq.setInstallFolder(fullfile(tempdir, "MPyReq"));
MPyReq.autoAcceptDownloadPrompts(true);
MPyReq.python("3.12");
MPyReq.pipPackage("<package_name>");
MPyReq.setInstallFolder(fullfile(tempdir, "MPyReq"));
MPyReq.autoAcceptDownloadPrompts(true);
MPyReq.python("3.12");
MPyReq.pipPackage("git+https://github.com/<org>/<repo>.git", Name="<RepoName>");
MPyReq.setInstallFolder(fullfile(tempdir, "MPyReq"));
MPyReq.autoAcceptDownloadPrompts(true);
MPyReq.python("3.11");
MPyReq.gitrepo("https://github.com/<org>/<repo>.git");
reqTxt = MPyReq.pathTo("<repo>") + filesep + "requirements.txt";
MPyReq.requirementTextFile(reqTxt, Name="<repo>Packages");
When the model uses torch.hub.load(), no git clone or weights download is needed — just install torch/torchvision:
MPyReq.setInstallFolder(fullfile(tempdir, "MPyReq"));
MPyReq.autoAcceptDownloadPrompts(true);
MPyReq.python("3.12");
MPyReq.pipPackage("torch");
MPyReq.pipPackage("torchvision");
% Model loads automatically via torch.hub:
model = py.torch.hub.load('org/repo', 'model_name');
Only needed when weights are NOT handled by torch.hub.load() or .from_pretrained():
MPyReq.weights("<weights_url>", DownloadTo=MPyReq.pathTo("<RepoName>") + filesep + "checkpoints");
Translate the Python inference example to MATLAB. Refer to these resource files for conversion rules and patterns:
Create a single demo<ModelName>.m file with clear sections:
%% Setup Python Environment
% Start with clean state (only if switching projects)
% terminate(pyenv); clear MPyReq
% Set installation folder (SSD recommended, ~15+ GB free space)
% Change this path to a suitable location on your machine
MPyReq.setInstallFolder(fullfile(tempdir, "MPyReq"));
MPyReq.autoAcceptDownloadPrompts(true);
MPyReq.python("<version>");
% ... package installation calls ...
%% Reference Python Code
%{
<paste the original Python inference code as a comment block>
%}
%% Load Model
% ... model loading code ...
%% Run Inference
% ... load input, run model, extract results ...
%% Visualize Results
% ... display/plot results ...
Check if a MATLAB MCP server tool is available in the current session (look for MCP tools like matlabRunCode, matlab_run, or similar).
MPyReq.python() and package installation calls through the MATLAB MCP server to verify the Python environment installs correctly.Track each fix-and-retry cycle as one attempt. Stop after a maximum of 5 attempts (combined across setup and inference). If the code is not fully working after 5 attempts:
demo<ModelName>.m — the version that got furthest (e.g., setup succeeded but inference failed, or partial inference ran).## What Works
- <list sections/steps that executed successfully>
## What Needs Attention
- <describe the remaining failure: error message, which line/section fails>
- <root cause hypothesis if known>
## Recommended Next Steps
1. <most likely fix — e.g., "Try Python 3.11 instead of 3.12 due to package compatibility">
2. <alternative approach — e.g., "Install system dependency X before running">
3. <manual verification — e.g., "Run `pip install <pkg>` in the MPyReq venv directly to check build logs">
## Environment Details
- Python version attempted: <version>
- Platform: <OS>
- Errors encountered: <brief summary of distinct errors across attempts>
%% Setup Python Environment — VERIFIED
% ... (code that ran successfully) ...
%% Run Inference — NEEDS MANUAL VERIFICATION
% The following section encountered errors during automated testing.
% See recommended next steps above.
% ... (best-effort code) ...
demo<ModelName>.m file to the user.Ctrl+Enter)UV_EXTRA_INDEX_URL).__enter__, __exit__, __init__, etc.) in MATLAB — double underscores are invalid MATLAB syntax. For context managers like torch.no_grad() or torch.inference_mode(), use the equivalent functional API (e.g., py.torch.set_grad_enabled(false/true)) instead of the with statement pattern.permute to reorder, then squeeze to remove singleton batch dims.[x1, y1, x2, y2] (corner pairs). MATLAB expects M x 4 as [startX, startY, width, height]. Convert with: boxes(:,3) - boxes(:,1) for width, boxes(:,4) - boxes(:,2) for height.imread for loading images — never use Python image libraries (PIL, OpenCV, etc.). Keep image I/O on the MATLAB side and convert to tensors for Python.%{ %} comment block for referencepy.importlib.import_module() when direct py.module.submodule doesn't work (deep nesting)UV_EXTRA_INDEX_URL may need to be setcd to a specific directory (e.g., for relative config paths), use cd(MPyReq.pathTo("<Name>"))For additional gotchas (class ID mapping, opencv-python issues, insertObjectAnnotation tips), see references/common_gotchas.md.
The following reference files are bundled with this skill. Read them from the skill's references/ directory:
The MPyReq class is in the project's mpyreq/MPyReq.m.
If this skill's guidance was wrong, incomplete, or didn't work, emit a plain-text feedback marker in your response, then continue with the task.
Format: IPCV-SKILL-FEEDBACK [matlab-integrate-pytorch-vision] [category]: what failed; what you did instead
Categories: wrong-command (incorrect/outdated), missing-guidance (omitted step),
discovery-failure (suggested approach didn't work), platform-issue (environment-specific)
Copyright 2026 The MathWorks, Inc.
manifest.yaml (opens in a new tab)references/common_gotchas.md (opens in a new tab)references/demo-birefnet.md (opens in a new tab)references/demo-cellpose.md (opens in a new tab)references/demo-depthpro.md (opens in a new tab)references/demo-sam2.md (opens in a new tab)references/demo-stardist.md (opens in a new tab)references/demo-vggt.md (opens in a new tab)references/image_conversion_patterns.md (opens in a new tab)references/python_matlab_conversions.md (opens in a new tab)references/readme.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
matlab, pytorch, computer-vision, mpyreq, image-processing, model-interfacing
/image-processing-and-computer-vision:matlab-integrate-pytorch-visionfrom image-processing-and-computer-vision
npx claudepluginhub matlab/matlab-agentic-toolkit --plugin image-processing-and-computer-vision10 skills in this plugin
/matlab-analyze-spectral-imagesWork with hyperspectral and multispectral images in MATLAB. Covers reading/writing (ENVI, NITF, TIFF, Sentinel-2, Landsat, ASTER), ECOSTRESS spectral libraries, processing (calibration, atmospheric correction, denoising, sharpening, dimensionality reduction, endmember extraction, unmixing, target/anomaly detection, spectral indices, segmentation), labeling (Spectral Image Labeler app, ground truth objects, automation algorithms), and deep learning (pixel classification CNNs, unmixing autoencoders, transfer learning). Use when reading, writing, processing, analyzing, classifying, labeling, or applying deep learning to hyperspectral or multispectral images./matlab-display-imageDisplay images and annotations for image processing, computer vision, and visual inspection. Use when displaying images with imageshow, creating image viewers with viewer2d, adding Regions of Interest (ROI) or annotations, overlaying masks or segmentations, streaming video frames, or building apps with image display./matlab-display-volumeDisplay 3-D image volumes, medical image volumes, surface meshes, and annotations for 3-D image processing. Use when displaying 3-D images or isosurfaces with volshow, creating volume viewers with viewer3d, adding Regions of Interest (ROI) or annotations, overlaying masks or segmentations, streaming volumetric data, or building apps with volume display./matlab-model-opticsBuild, import, analyze, tolerate, and optimize optical systems using the Optical Design and Simulation Library. Use when the user asks about optical systems, ray tracing, geometric optics, Zemax import, optical coatings, tolerancing, or optical design optimization.
/matlab-process-imagesLoad this first for any MATLAB task involving images, photos, scans, frames, volumes, or visual data — reading, writing, filtering, enhancing, denoising, sharpening, deblurring, thresholding, segmenting, masking, detecting, counting objects, removing backgrounds, measuring, registering, stitching, aligning, cropping, resizing, or transforming. Covers image I/O (TIFF, PNG, JPEG, RAW, HDR), histograms, edge detection, color, morphology, deep learning for images, quality assessment, and 3-D volumes. Also for image problems (dark, noisy, blurry, low contrast, uneven lighting, hazy, color cast) or data exploration (folder of images). Includes medical imaging I/O (DICOM, NIfTI, NRRD, medicalVolume) and large/blocked images (blockedImage, whole-slide). Skip if the user just wants you to look at an image, with no MATLAB work. Not for Simulink video-block models, C/C++/CUDA code generation or GPU deployment of a network, or point clouds. Hyperspectral and visual inspection have sibling skills.
/matlab-read-write-point-cloud-fileRead and write 3-D point cloud data using Lidar Toolbox file I/O. Covers PLY, PCD, LAS/LAZ, PCAP (Velodyne/Ouster/Hesai), E57, and IDC (Ibeo) formats. Use when loading point clouds from disk, saving to disk, choosing the correct reader or writer for a file format, extracting or preserving lidar point attributes, reading Ibeo IDC sensor recordings, or converting between formats.Other plugins' skills for the same job