Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/image-processing-and-computer-vision/matlab-integrate-pytorch-vision

matlab-integrate-pytorch-vision

Verified

Creates MATLAB interfaces to Python image processing and computer vision models from GitHub repositories or pip-installable packages using MPyReq. Use when asked to interface MATLAB with a Python CV/image model (segmentation, depth estimation, object detection, image generation, super-resolution, etc.), given a GitHub repo URL for an image/vision model, or asked to create an MPyReq demo for a deep-learning vision pipeline. Do NOT use for general-purpose Python-MATLAB interfacing, non-vision models (NLP, tabular, audio), model deployment/serving, or MATLAB-only image processing workflows.

references/demo-sam2.md

View on GitHub
# Demo: SAM2 (Git+pip Package with Weights)

Pattern: **B** — pip-installable git repo + explicit weights download.

## Setup

```matlab
terminate(pyenv); clear MPyReq

MPyReq.setInstallFolder(fullfile(tempdir, "MPyReq"));
MPyReq.autoAcceptDownloadPrompts(true);
MPyReq.python("3.12");
MPyReq.pipPackage("git+https://github.com/facebookresearch/sam2.git", ...
    Name="SAM2");
MPyReq.weights("https://dl.fbaipublicfiles.com/segment_anything_2/092824/" + ...
    "sam2.1_hiera_tiny.pt", ...
    DownloadTo=MPyReq.pathTo("SAM2") + filesep + "sam2" + filesep + "checkpoints");
```

## Reference Python Code

```python
import torch
from sam2.build_sam import build_sam2
from sam2.sam2_image_predictor import SAM2ImagePredictor
checkpoint = "./checkpoints/sam2.1_hiera_large.pt"
model_cfg = "configs/sam2.1/sam2.1_hiera_l.yaml"
predictor = SAM2ImagePredictor(build_sam2(model_cfg, checkpoint))
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
    predictor.set_image(<your_image>)
    masks, _, _ = predictor.predict(<input_prompts>)
```

## Inference

```matlab
build_sam2 = py.importlib.import_module('sam2.build_sam').build_sam2;
SAM2ImagePredictor = py.importlib.import_module('sam2.sam2_image_predictor').SAM2ImagePredictor;
checkpoint = MPyReq.pathTo("SAM2") ...
    + filesep + "sam2" + filesep + "checkpoints" + filesep + "sam2.1_hiera_tiny.pt";
model_cfg = "configs/sam2.1/sam2.1_hiera_t.yaml";
predictor = SAM2ImagePredictor(build_sam2(model_cfg, checkpoint));

im = imread("AT3_1m4_02.tif");
im = repmat(im, [1 1 3]);  % SAM needs RGB
predictor.set_image(im);

point_coords_py = py.torch.tensor(int32([70, 300; 70 300]));
point_labels_py = py.torch.tensor(int32([1, 1]));
outputs = predictor.predict(point_coords=point_coords_py, ...
    point_labels=point_labels_py);
mask = single(outputs{1});
mask = permute(mask, [2 3 1]);
imageshow(labeloverlay(im, mask(:,:,3)))
```

## Notes

- Uses `py.importlib.import_module` for deep submodule access.
- SAM2 requires RGB input — replicate grayscale with `repmat(im, [1 1 3])`.
- Mask output is permuted from Python's CHW to MATLAB's HWC ordering.
- The `with torch.inference_mode()` context manager is NOT used — MATLAB cannot call dunder methods.

----

Copyright 2026 The MathWorks, Inc.

----
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall