{"id":13571906,"url":"https://github.com/nekitmm/starnet","last_synced_at":"2025-08-08T17:11:24.244Z","repository":{"id":37460042,"uuid":"126673332","full_name":"nekitmm/starnet","owner":"nekitmm","description":"StarNet","archived":false,"fork":false,"pushed_at":"2022-09-12T22:34:37.000Z","size":37982,"stargazers_count":276,"open_issues_count":7,"forks_count":32,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-02T11:05:25.485Z","etag":null,"topics":["astro","astronomy","deep-learning","deep-neural-networks","gan","gans","image-manipulation","image-processing","neural-network","perceptual-losses","pix2pix","star","star-removal","starless-images","starnet","tensorflow","transformation"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nekitmm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-25T07:10:40.000Z","updated_at":"2025-03-31T18:05:33.000Z","dependencies_parsed_at":"2023-01-17T14:45:26.343Z","dependency_job_id":null,"html_url":"https://github.com/nekitmm/starnet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekitmm%2Fstarnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekitmm%2Fstarnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekitmm%2Fstarnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nekitmm%2Fstarnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nekitmm","download_url":"https://codeload.github.com/nekitmm/starnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045231,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astro","astronomy","deep-learning","deep-neural-networks","gan","gans","image-manipulation","image-processing","neural-network","perceptual-losses","pix2pix","star","star-removal","starless-images","starnet","tensorflow","transformation"],"created_at":"2024-08-01T14:01:08.118Z","updated_at":"2025-04-09T13:05:54.571Z","avatar_url":"https://github.com/nekitmm.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"\u003ch1\u003eUpdate 2\u003c/h1\u003e\r\n Updated documentation for using Tensorflow-directml on windows for broad support on any modern gpu with sufficient memory.\r\n\r\n\u003chr\u003e\r\n\u003ch1\u003eUpdate\u003c/h1\u003e\r\n\r\nPushed a new implementation os starnet in TF2.x. The whole implementation is in one file *starnet_v1_TF2.py*.\r\n\r\nI also created a few Jupyter notebooks for ease of use:\r\n\r\n1. starnet_v1_TF2_transform.ipynb - loads and transforms an image.\r\n2. starnet_v1_TF2.ipynb - more detailed example that loads a model and shows how to train it (really simple as well I think).\r\n\r\nWeights for the new model can be found \u003ca href=\"https://www.dropbox.com/s/lcgn5gvnxpo27s5/starnet_weights2.zip?dl=0\"\u003ehere\u003c/a\u003e.\r\n\r\n\u003chr\u003e\r\n\r\n**StarNet** is a neural network that can remove stars from images in one simple step leaving only background.\r\n\r\nMore technically it is a convolutional residual net with encoder-decoder architecture and with L1, Adversarial and Perceptual losses.\r\n\r\n**Small example:**\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n  \u003cimg src=\"https://github.com/nekitmm/starnet/blob/master/for_git/1.jpg\"\u003e\u003cbr\u003e\u003cbr\u003e\r\n\u003c/div\u003e\r\n\r\n\u003ccenter\u003e\u003ch1\u003eIntro\u003c/h1\u003e\u003c/center\u003e\r\n\r\nStar removal using classical methods is a very tricky and painful multi-step procedure, which is hard to master\r\nand hard to get nice results from, especially in case of images busy with stars.\r\n\r\nThis neural net will remove most of stars from input image in one step, leaving only really huge ones, and leaving (well, hopefully)\r\nintact all other small bright things whose shape is significantly different from that of a typical star, like small spiral\r\ngalaxies, fine details in nebulosity, HH objects, etc.\r\n\r\nIt is intended to be used by astrophotographers. Primary use is for background nebulosity enhancement in rich star fields,\r\nbut it can also help in creation of nice starless image.\r\n\r\n\u003ccenter\u003e\u003ch1\u003eLiterature\u003c/h1\u003e\u003c/center\u003e\r\n\r\nThis code is partially based on pix2pix code and ideas from pix2pix paper.\r\n\r\npix2pix code: https://github.com/phillipi/pix2pix\r\n\r\npix2pix paper: \u003ca href=\"https://arxiv.org/pdf/1611.07004v1.pdf\"\u003eImage-to-Image Translation with Conditional Adversarial Networks\u003c/a\u003e\r\n\r\nUdea of using Perceptual Adversarial losses is from this paper as well as some other ideas:\r\n\r\n\u003ca href=\"https://arxiv.org/abs/1706.09138\"\u003ePerceptual Adversarial Networks for Image-to-Image Transformation\u003c/a\u003e\r\n\r\nOther papers I took ideas from or found useful during development:\r\n\r\n\u003ca href=\"https://arxiv.org/abs/1701.05957\"\u003eImage De-raining Using a Conditional Generative Adversarial Network\u003c/a\u003e\r\n\r\n\u003ca href=\"https://arxiv.org/abs/1606.08921\"\u003eImage Restoration Using Convolutional Auto-encoders with Symmetric Skip Connections\u003c/a\u003e\r\n\r\n\u003ca href=\"http://www.columbia.edu/~jwp2128/Papers/FuHuangetal2017.pdf\"\u003eRemoving rain from single images via a deep detail network\u003c/a\u003e\r\n\r\n\u003ccenter\u003e\u003ch1\u003eUsage\u003c/h1\u003e\u003c/center\u003e\r\n\r\nIts primary purpose is to partially replace initial steps of star removal in tutorials, like one by Gerald Wechselberger,\r\naiming to enhance nebulosity without pushing stars up. The tutorial itself was available under\r\n\u003ca href=\"https://dl.dropboxusercontent.com/u/57910417/Howto_enhance_nebuala_without_pushing_stars.wmv\"\u003ethis\u003c/a\u003e link, but not any more,\r\nfor some reason. Haven't found any newer links to it. Anyway, you got the idea.\r\n\r\n\u003ccenter\u003e\u003ch1\u003eSuggested Work Flow\u003c/h1\u003e\u003c/center\u003e\r\n\r\nThe transformation by this neural net can be part of PixInsight/Photoshop processing work flow. Something like this:\r\n\r\n1. Start from **stretched** LRGB image. Save as 8 bits/channel tif file.\r\n2. Feed to StarNet.\r\n3. Open output in Photoshop, correct some of the worst artifacts that will most likely appear in the image. If there are huge stars\r\nin the image left, you will have to take care of them in some other way.\r\n4. Perhaps use some noise reduction (we don't want to push noise up).\r\n5. Use resulting image to enhance nebulosity using some method (Screen-Mask-Invert for example) or enjoy the result.\r\n6. ?\r\n7. Profit!\r\n\r\n\u003ccenter\u003e\u003ch1\u003eWeights for the network\u003c/h1\u003e\u003c/center\u003e\r\n\r\nThis repository contains only a code base needed to run the net, but does not contain all the weights (which are uploaded into LFS.\r\nPre-trained weights are also available for now through my dropbox account\r\nbecause they weight too much (lol) - about 700 Mb. You need to download them and unpack into root folder of starnet (the one with all\r\npython scripts, not into some sub-folder) to begin using StarNet:\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n\u003ca href=\"https://www.dropbox.com/s/atcs42ox4n99w96/starnet_weights.zip?dl=0\"\u003eLINK\u003c/a\u003e\r\n\u003c/div\u003e\r\n\r\nThis will rewrite some files in this repo!\r\n\r\nThe weights are also uploaded into LFS, but depending how you clone the repo they might or might not download.\r\n\r\n\u003ccenter\u003e\u003ch1\u003eSome tips and tricks\u003c/h1\u003e\u003c/center\u003e\r\n\r\n1. Do not use heavily processed images for input. If star shapes are unusual (if star reduction techniques were used, too much sharpening,\r\ndeconvolution, image was heavily resized, etc) the performance might be much worse than it could be. I am almost sure. Or maybe it will be\r\nbetter in your case, but that's unlikely.\r\n\r\n2. This newral net was trained using data from refractor telescope (FSQ106 + QSI 683 wsg-8), so will work best for data from similar imaging\r\nsystems. That's a bit of a bad news for many users of reflector telescopes. If you have long spikes in your images, then the net will not take\r\ncare of these spikes very well, I tried and didn't like results too much. What you can do, however, is you can train the net a bit more\r\nusing your own data. Just prepare one or two starless images from your data and run training for 20 epochs or so. This should significantly\r\nimprove results and make the net much better for **your** data.\r\n\r\n3. The point above is valid for all images, for which you are not getting good results. You can prepare a starless version even of a **small\r\npart** of that image (but not smaller than 256x256 pixels) and run training for 20 epochs or so on this image. This should improve quality of\r\ntransformation of the whole image. This will take a lot of time, of course, but in the end you not only getting a starless image, but also\r\ntrain a net so it will perform better next time on a similar image.\r\n\r\n4. Also it might help, for example, to make image brighter (darker) if it is unusually dark (bright), or things like that.\r\n\r\n5. Sometimes the net will leave small stars in the output, if you feed it very busy image. In this case it is helpful to feed output to the \r\nnet again.\r\n\r\n\u003ccenter\u003e\u003ch1\u003eTraining Dataset\u003c/h1\u003e\u003c/center\u003e\r\n\r\nThis is one part I'd like to keep for myself for now, but you can create your own dataset creating starless versions of your images.\r\nOne extremely important note: the only difference between two images (original and starless) should be stars, which are replaced\r\nby background in the starless version. The rest of the image should be perfectly intact. If you will throw in a starless image which\r\nis super nice looking, but in a process of creation of this image you altered much more than just stars, this will only degrade\r\nnetwork performance. Also be aware that quality of star removal by the net will never be better than that in your training set, so\r\nif you want a top-notch quality starless images, be ready to provide training images of even higher quality.\r\n\r\nI left one training image to show organization of folders my code expects. Inside a folder named 'train' there are two sub-folders named\r\n'original' and starless', both should contain equal number of images with identical name pairs.\r\n\r\n\u003ccenter\u003e\u003ch1\u003eSome technical info\u003c/h1\u003e\u003c/center\u003e\r\n \r\nThroughout the code all input and output images I use are 8 bits per channel **tif** images.\r\nThis code should read some other image formats (like jpeg, 16bit tiff, etc), but I did not check all of them.\r\n\r\n\u003ccenter\u003e\u003ch1\u003ePrerequisites and installation Guide\u003c/h1\u003e\u003c/center\u003e\r\n\r\nfor all environments, using conda is strongly encouraged, installation instructions assume a conda install of either Anaconda python or miniconda:\r\n  - https://docs.conda.io/en/latest/miniconda.html\r\n\r\n## Windows (New!)\r\n\r\nOn windows we can now run starnet on GPU on any modern graphics card! (yes AMD and Intel included)\r\n\r\n### Prerequisites\r\n\r\nWindows 10 Version 1709, 64-bit (Build 16299 or higher) or Windows 11 Version 21H2, 64-bit (Build 22000 or higher)\r\n\r\n### Installation\r\n\r\nOnce anaconda is installed, you can open an \"anaconda powershell prompt\" to proceed.\r\n\r\nWe use the environment config file provided to configure and install all the dependencies:\r\n\r\n#### With GPU support (Windows):\r\n```\r\nconda env create -f environment-windows.yml\r\n```\r\n#### With CUDA support (linux or windows):\r\n```\r\nconda env create -f environment-lnx-cuda.yml\r\n```\r\n#### CPU only(Mac, Linux, Windows):\r\n```\r\nconda env create -f environment-cpu.yml\r\n```\r\n### Post installation\r\nInitialize the environment with:\r\n```\r\nconda activate starnet\r\n```\r\nAnd you're ready to go!\r\n\r\n\r\nOriginally tested on:\r\n- Win 10 + Cygwin\r\n- NVidia GeForce 840M 2Gb, compute capability 5.0, CUDA version 9.1\r\n\r\nWindows general GPU support tested on:\r\n- Win 10 12H1\r\n- AMD RX 6800-XT 16GB\r\n\r\n\u003ccenter\u003e\u003ch1\u003eUsage\u003c/h1\u003e\u003c/center\u003e\r\n \r\n      \r\n      python.exe -u starnet.py transform \u003cinput_image\u003e - The most probable use. This command will transform \r\n                                                         input image (namely will remove stars) and will \r\n                                                         create a mask showing changes regions. Output images\r\n                                                         names will be \u003cinput_image\u003e_starless.tif and\r\n                                                         \u003cinput_image\u003e_mask.tif\r\n      \r\n      python.exe -u starnet.py train                   - Use if you want to train the model some more using\r\n                                                         your training data. This will also output logs and\r\n                                                         showcases of training transformations in \r\n                                                         './logs' sub-folder.\r\n                                                         \r\n      python.exe -u starnet.py plot                    - Will plot graphs from log files inside './logs' \r\n                                                         sub-folder.\r\n      \r\n      python.exe -u starnet.py train new               - Use only if you want to train a completely new model,\r\n                                                         erasing all older weights and other output, such as\r\n                                                         logs. Use only if you know what you are doing!\r\n \r\n      python.exe -u starnet.py test \u003cinput_image\u003e      - This will create some test transformations of patches\r\n                                                         of the input. Similar to transform, but instead of\r\n                                                         transforming an entire image, will create showcases\r\n                                                         of transformations. Fast option to take a look at \r\n                                                         possible result.\r\n                                                         By default output will be in './test' sub-folder.\r\n\r\n\r\n\u003ccenter\u003e\u003ch1\u003eCouple more examples\u003c/h1\u003e\u003c/center\u003e\r\n\r\nMore examples can be found \u003ca href=\"https://www.astrobin.com/339099/0/\"\u003ehere\u003c/a\u003e.\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n  \u003cimg src=\"https://github.com/nekitmm/starnet/blob/master/for_git/2.jpg\"\u003e\u003cbr\u003e\u003cbr\u003e\r\n\u003c/div\u003e\r\n\r\nOriginal:\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n  \u003cimg src=\"https://github.com/nekitmm/starnet/blob/master/for_git/3.jpg\"\u003e\u003cbr\u003e\u003cbr\u003e\r\n\u003c/div\u003e\r\n\r\nStarless:\r\n\r\n\u003cdiv align=\"center\"\u003e\r\n  \u003cimg src=\"https://github.com/nekitmm/starnet/blob/master/for_git/4.jpg\"\u003e\u003cbr\u003e\u003cbr\u003e\r\n\u003c/div\u003e\r\n\r\n\r\n\u003ccenter\u003e\u003ch1\u003eFAQ\u003c/h1\u003e\u003c/center\u003e\r\n\r\n**What is all this 'python-sudo-mumbo-jumbo'**?\r\n\r\nThis whole thing works as command line program, which means that there is no graphical interface: you have to\r\nrun it in a console using some text commands (like ones you see above) and it outputs text (and writes image files\r\nof course!).\r\n\r\n2. Where exactly do I put weights of the network?\r\n\r\nAll the files you download should be in one folder: all the files with extension .py (starnet.py, train.py, transform.py, etc.) should\r\nbe in the same folder with weights for the network (model.ckpt.data-00000-of-00001, model.ckpt.index, model.ckpt.meta, etc.)\r\n\r\n\u003ccenter\u003e\u003ch1\u003eSome Troubleshooting\u003c/h1\u003e\u003c/center\u003e\r\n\r\n1. \u003cb\u003eError: 'No package named tensorflow'.\u003c/b\u003e Should be pretty self-explanatory: your python can not find tensorflow. That means you did not\r\nrun pip to install it (\u003cb\u003epip install tensorflow\u003c/b\u003e) or something went wrong during this step if you did.\r\n\r\n2. \u003cb\u003eError: 'ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory.'\u003c/b\u003e You are trying to use GPU version of\r\ntensorflow and you don't have CUDA properly installed.\r\n\r\n3. \u003cb\u003eError: 'ValueError: The passed save_path is not a valid checkpoint: ./model.ckpt.'\u003c/b\u003e You did not copy network weights into proper location. See above.\r\n\r\nLet me know if you have any other issues with the code. (Preferably through *Astrobin*)\r\n\r\n\u003ccenter\u003e\u003ch1\u003eLicenses\u003c/h1\u003e\u003c/center\u003e\r\n\r\nCode is available under MIT License, please review LICENSE.md file inside repo. Its very permissive, but no liability\r\nor warranty of any kind.\r\n\r\nWeights are available under \u003ca href=\"https://creativecommons.org/licenses/by-nc-sa/4.0/\"\u003e\r\nAttribution-NonCommercial-ShareAlike 4.0 International Creative Commons\u003c/a\u003e license.\r\n\r\nIn short:\r\nYou are free to use and redistribute them in any medium or format, but only **under the same** license terms.\r\nYou can transform, and build your projects upon them.\r\nYou can **NOT** use them for commercial purposes.\r\nYou must give appropriate credit for usage of these weights.\r\n\r\nThe weights are distributed on an \"AS IS\" BASIS WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnekitmm%2Fstarnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnekitmm%2Fstarnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnekitmm%2Fstarnet/lists"}