Skip to content
/ ISETPy Public

Collecting up Python methods that we may want to use from ISET repositories.

License

Notifications You must be signed in to change notification settings

ISET/ISETPy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

ISETPy

We are starting to make it simpler to call Python libraries from Matlab. We did this for the HDR simulations isethdrsensor. In that case, it enabled running neural networks trained with PyTorch. We expect that there will be more cases in which we incorporate Python libraries with ISETCam calculations. This repository is intended to document a general approach and to make it easy to call some obvious libraries. (OpenCV ...?)

Creating a Python environment (MAC terminal)

We recommend Miniconda installation on the Mac. Here are installation suggestions

  • Download the miniconda installer. There is both an Apple Silicon version and an Intel version. Here is the link to the Miniconda installer

  • After miniconda installation, update conda using this command

conda update -n base -c defaults conda

  • We are using the py39 version. Set that environment using the conda command

conda create -n py39 python=3.9

  • Activate the environment with this version of python

conda activate py39

You will then have a py39 environment activated as a python environment, which you can see in the terminal window (zsh). That is the environment we will call from MATLAB.

ISETCam setup

Our first example was using neural network ONXX files in the isethdrsensor repository. See that repository for the full instructions.

The principles are here:

Incorporating the requirements

To run your code, you probably need to have your environment include some libraries. We suppose that each project will have a requirements.txt file, or something like it. For the isethdrsensor repository, we placed the file in utility/python/requirements.txt. We changed into that directory and ran

pip install -r requirements.txt

That installed the necessary libraries.

Matlab python environment

(Sonoma version of the MacOS)

Matlab manages an interface to Python, which they create using the pyenv command.

pyenv('Version','/opt/miniconda3/envs/py39/bin/python');

Confirm that Matlab communicates with Python

For example, try running

result = py.list([1, 2, 6]);

An example method

The isethdrsensor repository implemented the (Python) neural network call using this function: isetDemosaicNN

It is not awful, but it is a bit complicated. Have a look. This repository aims to keep hacking at the incorporation and making it simpler, both for ONXX files and other libraries.

About

Collecting up Python methods that we may want to use from ISET repositories.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published