StarNet - new module for star removal

yeah there's a chance it's just Mojave and Catalina but not 100% sure. anyway from the point of view of OSX it looks like someone is tampering with the PI binary when you try to install an unsigned module... so OSX prevents PI from loading the module. overall it's a good thing but in our case it turned out to be a hassle.

rob
 
I might not know programing but I too have the most up to date Mac OSX Mojave and with PixInsight 1.8.8.4 everything works fine and StarNet Installs> It is when I install the NEW PixInsight 1.8.8.5 that the problem occurs (still on Mojave.

So the new PI has problems with an older Mac and also a newer Mac. So logic would presume that it is PixInsght not Mac that has changed.


Steve
 
well no one actually said the problem was due to a change in OSX. the requirement for any dynamic library loaded by an application to be cryptographically signed by a valid apple developer is a compile-time option for applications.

the older versions of PI do not enforce this rule, but the newer versions do. that's all. that's why -4 and prior work and -5 (and presumably beyond) won't be able to load any third-party PI processes unless they were signed. i would sign it myself but i have to pay $100 so that apple will provide me with a certificate. since juan already has a developer certificate the most cost effective method is for him to sign the starnet dylib.

rob
 
I have reverted back to the prior version of PI .....and everything is as it should be - all scripts working!    Hopefully in the not to distant future the script can be loaded.
 
Hi Nikita,
I tried to install the module, but PI does not recognize it. I dowlnoaded the Starnet_PI folder and copied its contents into the folder C:\Program Files\PixInsight\bin.
I tried the command Install Module on the PI, the following messages appeared on a snall information window:

0 additional PixInsight module(s) were found on directory:
C:/Program Files/PixInsight/bin.

I'm running on windows 764 bits Ultimate up to date and with the last PI release.
Could you help me?

Thanks in advance for your support and best regards,
Sergio (Venice Italy)

Hi Sergio,

Ive just attached a new thread, because i am having the exact same issue. Did you ever resolve yours ?

John
 
Just installed the newest version of PI. 1.8.8-7

Well my wonderful starnet will not run... Any idea how to fix this? Starnet is so important to PI now that we love it. It is not the same experience without it.


StarNet: Processing view: light_FILTER_OIII_BINNING_2_integration

Writing swap files...

670.683 MiB/s

*** Error: File I/O Error: Invalid or empty file name

Reading swap files...

680.318 MiB/s

<* failed *>
 
New to PI, but struggling. I've found that starnet does not function on Mac Studio M1, on either OS 12.xxx, or 13.xxx. When I first discovered the issue I was running the older OS (12.xx). starnet was in the "bin", but would not load because:
“StarNet2-pxm.dylib” cannot be opened because the developer cannot be verified."
macOS cannot verify that this app is free from malware.
Safari downloaded this file today at 4:10 PM.

I then updated the OS to 13.xxx, and removed and downloaded PI fresh. I installed PI, ran the updates, and tried to find starnet again. Not in Processes, NOR in "bin". I downloaded from: https://www.starnetastro.com/download/, and moved the app to "bin". I attempted to install, and found the same results as above.

Seems to me PI has problems with Mac OS with apple silicon. I'm too new to fully know when something is not working, or I just do not know how to use it, but I suspect there are other problems. I do know (for instance) EZ denoise does not work, as it relies on starnet (I think).

Not sure this is relevant, but after shutting down PI I found a Terminal window open with notification that my username was now assigned to zsh?, or something similar. Unfortunately I did not bother to take a screen shot.

I do not see a way to report this to PI. Have I just missed it?

Any comments would be appreciated. I will also post this on a different page where Mac/M1 problems are being discussed.

(WBPP Mac Silicon Hangs)​

 
Seems to me PI has problems with Mac OS with apple silicon. I'm too new to fully know when something is not working, or I just do not know how to use it, but I suspect there are other problems. I do know (for instance) EZ denoise does not work, as it relies on starnet (I think).

Not sure this is relevant, but after shutting down PI I found a Terminal window open with notification that my username was now assigned to zsh?, or something similar. Unfortunately I did not bother to take a screen shot.

unfortunately it's the latter.

there's lots to unpack here.

Starnet1 as shipped with PI won't work on an M CPU. the module itself is compatible, but the libtensorflow libraries that ship with pixinsight have AVX2 and FMA instructions which rosetta2 does not emulate.

StarNet2 is compatible with M cpus, but you need to tell the OS that the binary is safe. after you get that warning you need to go into the system preferences, then to the security pane. on the main tab there will be a blurb at the bottom that says OSX prevented StarNet2 from loading. you need to click "run anyway". you might have to go thru this loop twice.

the other thing on M silicon is that the libtensorflow* files need to be put in /Applications/PixInsight/PixInsight.app/Contents/Frameworks/ in order for the OS to see them. you'll need to put the libraries there before you try to load the StarNet2 module.

the EZ suite depends on starnet1. darkarchon doesn't care enough to fix the code to be compatible with starnet2 or starxterminator, so you either have to try installing starnet1 to get this to work, or edit the EZ scripts to invoke starnet2 instead of starnet1. the tensorflow libraries that come with StarNet2 might work with StarNet1 but i've never tried it.

your username was not changed to zsh. that is the name of the default shell on OSX. the prompt probably just says "zsh" in it somewhere by default. the prompt on unix shells is customizable.

rob
 
Hi Rob,
Thanks much for the reply.
I'm going to delete PI, download, and install, and try starting "fresh".
John
 
Hi Rob,
Thanks much for the reply.
I'm going to delete PI, download, and install, and try starting "fresh".
John

ok -

just know that the PI installer will delete the StarNet dylib in order to avoid a crash on startup. so if you want to try installing StarNet (v1) you'll need to use Pacifist to extract the dylib from the installer package and manually put it into /Applications/PixInsight/bin/

but don't do this unless you delete the original /Applications/PixInsight/bin/libtensorflow* files and replace them with non AVX2/FMA versions (like the ones that come in the StarNetV2 zipfile.)

rob
 
Thanks Rob,
I did re-install PI, and followed the instructions provided by Sascha Wyss (YouTube:
). This does allow me to see Starnet2 among the processes, however it fails when executed. I get the following message:
>>>>>>>>>>
Starting star removal procedure...
Window size: 512
Stride: 256
Image size: 3704x3704
Number of channels: 3
Color space: RGB
Bits per sample: 16
Has alpha channels: false
Float sample: false
Restoring neural network checkpoint...

*** Error: Could not find checkpoint file in '/Applications/PixInsight/bin/'!

Reading swap files...
11541.068 MiB/s
<* failed *>

Rob, do you suppose PI will eventually provide an installer specifically for the m1 Mac? Would certainly be simpler than have all m1 owners struggling to find a way to make Starnet (either 1 or 2), work. I would have tried starnet 1 but did not find a place to download.
Thanks,
John
 
Thanks Rob,
I did re-install PI, and followed the instructions provided by Sascha Wyss (YouTube:
). This does allow me to see Starnet2 among the processes, however it fails when executed. I get the following message:
>>>>>>>>>>
Starting star removal procedure...
Window size: 512
Stride: 256
Image size: 3704x3704
Number of channels: 3
Color space: RGB
Bits per sample: 16
Has alpha channels: false
Float sample: false
Restoring neural network checkpoint...

*** Error: Could not find checkpoint file in '/Applications/PixInsight/bin/'!

Reading swap files...
11541.068 MiB/s
<* failed *>

Rob, do you suppose PI will eventually provide an installer specifically for the m1 Mac? Would certainly be simpler than have all m1 owners struggling to find a way to make Starnet (either 1 or 2), work. I would have tried starnet 1 but did not find a place to download.
Thanks,
John

it sounds like you didn't put the weights files in /Applications/PixInsight/bin/ ? double check that.

SN is 3rd party software written by Nikita Misiura. the history is this: Nikita wrote the module himself and built it for linux and windows. he didn't have access to a mac, so i built the mac version for him. at some point along the line, Juan (the author of PI) decided to refactor the code and start distributing StarNet (v1) with Pixinsight. everything was hunky dory until the Mx macs came out, and we discovered that the tensorflow library that juan used would not work with Rosetta2. rather than start carrying around multiple libraries, Juan decided to just stop supporting SN1 on the ARM architecture - the Mac installer now just deletes StarNet if the architecture is ARM. of course as i mentioned above, there is a workaround which is to get a tensorflow library that doesn't use those AVX2/FMA instructions.

at some point after this, Nikita improved StarNet and released StarNetV2. however, he used his original codebase as a starting point rather than the code that Juan refactored. he also decided to distribute it outside of the PI update framework. this is why it's so hard to install SNV2 on any machine.

the reason this is relevant is that when juan refactored the code he put in a way to point the SN1 process at the weights files no matter where you have them stored on disk. for whatever reason Nikita didn't like that idea for SNV2, so you are left with having to put the weights files in the exact place the module is looking for them or it won't work.

nikita removed starnetV1 from his own website since he feels V2 is superior. that's why you can't find it anywhere. however, you can use Pacifist.app to grab the StarNet-pxm.dylib file from the PixInsight installer, and download the weights files (there are 2 of them for SNV1) from the PI update system. since you got SNV2 working there's a chance the PI SNV1 will just work on your computer if you put the module in bin/ and tell PI to search for new modules.

anyway you are really close to having V2 working. i think all you have to do is put the weights file in the right place.

rob
 
Again, Thanks!
Eureka😳
Sascha Wyss actually mentioned this in his video. Unfortunately I just copied the "Lib" folder (containing the file), not the weight file. After moving the file out of the folder - success! In this case, there was/is only one file, and it does seem to have solved the problem.
Really, this is amazing support.
Thank you again.
John
 
A few thoughts to add here on the topic of StarNet and Apple Silicon, coming back to this subject after a year or so of futzing around trying to get StarNet to work within PixInsight on an Apple Silicon Mac and ideally to run on the GPU instead of CPU.

  • The core problem, which to the best of my knowledge remains unsolved, is that as of Jan 2023 there are still no libtensorflow C libraries for macOS which provide Metal/GPU support (whereas there are CUDA enabled libtensorflow C libraries available for Windows and Linux). Even after adding StarNet V2 back on an Apple Silicon Mac, I still haven't figured out a way to run it in anything but CPU only mode, which feels very slow after you've seen what's possible when running the tool via other mechanisms.

  • Running the old StarNet V1 (TF2 implementation) in the command-line python environment is still the best way to run StarNet on an Apple Silicon Mac IMHO. It's easy enough to leverage the M-chip GPU for substantially faster processing times; but, without an above-mentioned libtensorflow-metal C library, this method is unable to be integrated into the existing PI StarNet plug-in (as far as I know?). I've tried to compile a binary but this remains over my head and I've given up. The TensorFlow-metal release has been released for more than a year now and it seems nobody else has made such hypothetical C libraries either (as is the case with CUDA on Win/Linux) which has me wondering whether this is technically possible in the first place (??).

  • After an inordinate amount of time spent trying to integrate StarNet w/ GPU acceleration into PI on Apple Silicon, I've come to the conclusion that the cost of StarXTerminator really isn't so bad after all... (STX supports Apple Silicon out of the box and runs on the machine-learning task optimized "NPU" within the M-series SoC). Bottom line: STX solved this problem already.
Some benchmarks on a 16 megapixel greyscale 16-bit tif test file, running on my M2 MacBook Air.
  1. StarNet V1, CPU only: 214.7 seconds
  2. StarNet V2, (CPU only, PixInsight Plugin): ~150 seconds (I didn't feel like wrapping the script in a timer function, sorry! Faster than V1 but not by a ton)
  3. StarNet V1, (GPU, command line): 90.8 seconds
  4. STX PixInsight Plugin (NPU): 59.6 seconds
  5. Starnet++ Experimental MacOS CLI: 20.1 seconds!


Edit: March 2023 to add benchmark #5 above - StarNet++ reclaims the lead! Still, I see no way to call the CLI version of StarNet++ from inside PixInsight on macOS. For the Apple Silicon version StarNet++ has now moved from Tensorflow to PyTorch for the heavy lifting. Thus I assume the PI Module would need to be updated to be compatible with these revisions (i.e. not possible to kludge together a solution by manually manipulating library files in the PI application folder). Hopefully a PixInsight module update will be forthcoming - as it is StarNet++ is now faster via CLI on macOS by nearly a factor of 10!
 
Last edited:
Back
Top