Is there a Openflexure mirror that comes with Python 3.9/64-bit architecture preconfigured?

Hi not sure if anyone has asked about this before but it’s been causing me a bit of a headache the last couple of days.

I am trying to write some python code which will use the cellpose package for image segmentation of some HeLa cells in brightfield. The hope is to use the microscope as a cell counter, and all code would ideally run on the Rpi itself, without having to run anything over SHH on another computer. However, cellpose is only compatible with Python 3.9+. I have tried using pyenv to create a venv with Python 3.9 on the Rpi, but this has caused me nothing but headaches for the last couple of days with stuff like ldd version mismatches.

As I cannot use miniforge on armhf, even installing cellpose on a Rpi running Python 3.9 would require compiling almost everything from source - including PyTorch, which would take an entire day. I thought I would try to simply install a rapbian mirror already running Python 3.9 or later, and then install OpenFlexureServe following the instructions on GitHub, however I didn’t have much luck and I’m assuming there must be some problem with compatability. Is there a simple way to make later versions of Python work on the OpenFlexure Rpi that I am simply unaware of, and have people found ways around it? Lastly, are there any plans to upgrade the mirror to one running later versions of python?

Changing the underlying version of python is a huge upgrade. There is a big push to modernise the software stack in v3 of the software. You can try to use the v3 test images, the issue is that the images are only the “lite” version of the operating system.

Some of the discussion on this is happening in this software thread.

One slightly hacky way to do it would be to have a second version of python installed (using something like the deadsnakes PPA). You could then have one 3.9+ version of python doing you code while the server runs in a different python version and environment.

1 Like

The other very-hacky way would be to run the Openflexure software lite on the very minimum Pi (should work on a zero2, I got one but never tested it and it is not on the recommended list. It certainly works on a Pi3 which are often available at low cost) then you can use a Pi4 or Pi5 with the latest Pi OS, latest Python etc, which would fit in not much larger base.

1 Like

Thank you both for your suggestions!

I didn’t think to use a zero because, as @WilliamW said, I didn’t see it on the minimum recomended list for running OFC, however I’d be interested to see how well it performs. I’m currently using the approach suggested by @j.stirling which, albeit a bit annoying, I think should work.

In the interim I’ve installed cellpose 1.0.2 which I’ve only recently realised is compatible with Python 3.7 and should work for now (although it is missing features for training your own models which is what I would ultimately want to use).

2 Likes

I rewrote the openflexure system on a recent 64-bit version of Raspbian over a weekend, I’ll put it up on github for you. It does rely on the Sangaboard for motor control.

3 Likes

I forked the image customizer to make a 64bit version with v3 software. Let me know if your still looking and I can send you the compiled image.

1 Like

Wow this looks great!

The use-case I mentioned above was a bit of a side project for which I ended up setting up a Github action to do all my image segmentation and analysis from. This is of course very slow and requires an internet conenction, however works fine for what I wanted out of it (an easy to use/cheap cell counter for some masters students to use for in vitro work). The reason I did this is because even though I got cellpose working locally using a seperate Python env, I think PyTorch performance on the 32 bit rapbian is very poor, and the runtime was actually slower than the Github actions approach I eventually settled on.

If you still have the compiled image I’d love to have a look at it! Ultimately, I would like to do a easy to follow write-up for people to be able to build the cell-counter as simply as they would the basic OFM, so if I can get all code running locally that would a great help!

Thank you once again!

You made me realize the changes I made to the code don’t work :sweat_smile: because last time I did it I edited some files manually on the SD card. I fixed some of it up and I tested the image and it works good.

I’m uploading the image right now. When its finished in the morning Ill add a link.

Edit:

2 Likes