Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates from csbdeep, refactor gui + enhancements, fold in cli
Browse files Browse the repository at this point in the history
p7ayfu77 committed Mar 6, 2024
1 parent ac43878 commit 9b42b37
Showing 58 changed files with 2,827 additions and 2,377 deletions.
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -8,19 +8,13 @@ __pycache__/
*.egg-info/
build/
dist/
dist-gui/
astrodenoisepy/dist/
astrodenoisepy/dist-gui/
docs/build/
data/**
example_data
htmlcov/
wandb/
models/**
.coverage*
*.npz
*.tif*
*.hdf5
*.h5
*.zip
*.tfevents.*
config.json
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -12,5 +12,6 @@
},
"jupyter.notebookFileRoot": "${workspaceFolder}",
"python.defaultInterpreterPath": ".\\.venv\\Scripts\\python.exe",
"jupyter.debugJustMyCode": false
"jupyter.debugJustMyCode": false,
"python.analysis.typeCheckingMode": "basic"
}
83 changes: 66 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Astro CSBDeep – a toolbox for CARE with some tweaks
# Astro CSBDeep – a toolbox for training and using denoise models for Astrophotography

**NOTE: This is a fork of [CSBDeep](https://github.com/CSBDeep/CSBDeep). Thank you to the developers.**

@@ -20,26 +20,14 @@ You will need a few things to get started:

Key Dependencies are:

* python:3.7-3.9
* cuDNN:8.1
* CUDA:11.2
* python:3.9
* [cuDNN:8.9.7](https://developer.nvidia.com/rdp/cudnn-archive)
* [CUDA:11.8](https://developer.nvidia.com/cuda-11-8-0-download-archive)
* jupyter:1.0.0
* tensorflow-gpu:2.7.0
* tensorflow-gpu:2.10.0

Please check the `requirements.txt` file for versions of the above and other packages used to test the example Jupyter Notebook.

## Example Notebook For Astro

The example notebook for astrophotography `AstroNoise2Noise.ipynb` can be opened in jupyter and used to step through the process.

Further details are documented in the notebook.

In your venv start up jupiter:

```
(.venv) C:\CSBDeep> jupyter notebook
```

## Working in Visual Studio Code

Once you have you have a python venv and dependencies are installed fire up VS Code.
@@ -61,6 +49,67 @@ Open up the notebook `AstroNoise2Noise.ipynb` and configure the same python inte

Happy coding and clear skies!

## Example Notebook For Astro Image Training

The example notebook for astrophotography `AstroNoise2Noise.ipynb` can be opened in jupyter and used to step through the process.

Further details are documented in the notebook.

In your venv start up jupiter:

```
(.venv) C:\CSBDeep> jupyter notebook
```

## AstroDenoise Command Line Tool

You can use the AstroDenoise cli commands to denoise your image using your custom model.

```
(.venv) C:\CSBDeep> python -m astrodenoise.main myimage.tif
```

See the arguments help for additional options.

```
(.venv) C:\CSBDeep> python -m astrodenoise.main -h
usage: AstroDenoise.exe [-h] [--model MODEL] [--models_folder MODELS_FOLDER] [--tiles TILES] [--overwrite]
[--device {GPU,CPU}] [--normalize] [--norm-C NORM_C] [--norm-B NORM_B] [--norm-restore]
input
positional arguments:
input Input image path, either tif or debayered fits file with data stored as 32bit float.
optional arguments:
-h, --help show this help message and exit
--model MODEL, -m MODEL
Alternative model name to use for de-noising.
--models_folder MODELS_FOLDER
Alternative models folder root path.
--tiles TILES, -t TILES
Use number of tiling slices when de-noising, useful for large images and limited memory.
--overwrite, -o Allow overwrite of existing output file. Default: False when not specified.
--device {GPU,CPU}, -d {GPU,CPU}
Optional select processing to target CPU or GCP. Default: CPU
--normalize, -n Enable STFNormalization before de-noising. Default: False when not specified.
--norm-C NORM_C C parameter for STF Normalization. Default: -2.8
--norm-B NORM_B B parameter for STF Normalization, Higher B results in stronger stretch providing the ability
target de-noising more effectively. . Default: 0.25, Range: 0 < B < 1
--norm-restore Restores output image to original data range after processing. Default: False when not
specified.
```

## AstroDenoise GUI

You can use the AstroDenoise GUI to interactively denoise your image using your custom model.

Start the GUI by running the `astrodenoise.main` module entrypoint without arguments.

```
(.venv) C:\CSBDeep> python -m astrodenoise.main
```

## Contributors

Want to say a big thank you to the CSBDeep team who provided their framework along with great examples to get started.
1 change: 1 addition & 0 deletions astrodenoise/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from __future__ import absolute_import, print_function
60 changes: 60 additions & 0 deletions astrodenoise/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from pathlib import Path

from kivy.app import App
from kivy.properties import StringProperty
from kivy.core.window import Window
from kivy.config import Config

from astrodenoise.version import version, modelversion

class AstroDeNoiseApp(App):
def __init__(self, **kwargs):
super(AstroDeNoiseApp, self).__init__(**kwargs)
self.lastpath = ""

lastpath = StringProperty()
lastmodel = StringProperty()

def build(self):
self.title = f"AstroDenoise - v{version}"
Window.bind(on_request_close=self.window_request_close)
config = self.config

if config is not None:
Window.left = config.getint('graphics', 'left')
Window.top = config.getint('graphics', 'top')
Window.size = (config.getint('graphics', 'width'), config.getint('graphics', 'height'))
self.lastpath = config.get('astrodenoise', 'lastpath')
self.lastmodel = config.get('astrodenoise', 'lastmodel')

Config.set('input', 'mouse', 'mouse,disable_multitouch')

def build_config(self, config):
config.setdefaults('graphics', {
'width': 1024,
'height': 768,
'top': 100,
'left': 100
})

config.setdefaults('astrodenoise', {
'lastpath': '',
'lastmodel': modelversion
})

def window_request_close(self, win):

config = self.config
if config is not None:
config.set('graphics', 'left', Window.left)
config.set('graphics', 'top', Window.top)
config.set('graphics', 'width', Window.system_size[0])
config.set('graphics', 'height', Window.system_size[1])
config.set('astrodenoise', 'lastpath', Path(self.lastpath).as_posix())
config.set('astrodenoise', 'lastmodel', self.lastmodel)
config.write()

return False

def get_app(running_app) -> AstroDeNoiseApp:
return running_app
Loading

0 comments on commit 9b42b37

Please sign in to comment.