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-stardist.md

View on GitHub
# Demo: StarDist (Complex Dependency Management)

Pattern: **A** with extra complexity — multiple pip packages with version conflict resolution.

## Setup

```matlab
terminate(pyenv); clear MPyReq

useGPU = false;

MPyReq.setInstallFolder(fullfile(tempdir, "MPyReq"));
MPyReq.autoAcceptDownloadPrompts(true);
MPyReq.python("3.12");
MPyReq.pipPackage("setuptools");
MPyReq.pipPackage("stardist");

if useGPU
    tfName = "tfcuda";
    MPyReq.pipPackage("tensorflow[and-cuda]", Name=tfName);
else
    tfName = "tf";
    MPyReq.pipPackage("tensorflow", Name=tfName);
end

% Remove newer numpy due to compatibility issues
% See: https://github.com/stardist/stardist/issues/291
isNumPy2Removed = false;
numpy2str = MPyReq.pathTo("stardist") + filesep + "numpy-2*";
numpy2dir = dir(numpy2str);
if ~isempty(numpy2dir)
    toDelete = dir(MPyReq.pathTo("stardist") + filesep + "numpy*");
    for i = 1:length(toDelete)
        if isfolder(fullfile(toDelete(i).folder, toDelete(i).name))
            rmdir(fullfile(toDelete(i).folder, toDelete(i).name), "s");
        else
            delete(fullfile(toDelete(i).folder, toDelete(i).name));
        end
    end
    isNumPy2Removed = true;
end

numpy2str = MPyReq.pathTo(tfName) + filesep + "numpy-2*";
numpy2dir = dir(numpy2str);
if ~isempty(numpy2dir)
    toDelete = dir(MPyReq.pathTo(tfName) + filesep + "numpy*");
    for i = 1:length(toDelete)
        if isfolder(fullfile(toDelete(i).folder, toDelete(i).name))
            rmdir(fullfile(toDelete(i).folder, toDelete(i).name), "s");
        else
            delete(fullfile(toDelete(i).folder, toDelete(i).name));
        end
    end
    isNumPy2Removed = true;
end

if isNumPy2Removed
    terminate(pyenv); clear MPyReq
    MPyReq.python("3.12");
    MPyReq.pipPackage("setuptools");
    MPyReq.pipPackage("stardist");
    if useGPU
        MPyReq.pipPackage("tensorflow[and-cuda]", Name=tfName);
    else
        MPyReq.pipPackage("tensorflow", Name=tfName);
    end
end

% Install and use older numpy
MPyReq.pipPackage("numpy==1.26.4");
```

## Inference

```matlab
model = py.stardist.models.StarDist2D().from_pretrained('2D_versatile_fluo');
model.config.use_gpu = useGPU;

im = uint8(py.stardist.data.test_image_nuclei_2d());
ims = im2single(im);
outputs = model.predict_instances(ims);
labels = uint16(outputs{1});
imageshow(im, OverlayData=labels)
```

## Notes

- Demonstrates handling numpy version conflicts by manually removing incompatible numpy 2.x and pinning to 1.26.4.
- After removing packages from the install folder, `terminate(pyenv); clear MPyReq` is required to reload the environment.
- GPU/CPU toggle requires a full environment reset if changed after initial setup.
- Uses `.from_pretrained()` which auto-downloads model weights.
- StarDist accepts `im2single` input directly — no manual NCHW conversion needed.

----

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