DeepSNR CLI for macOS arm64 - CoreML Backend
============================================

DeepSNR is a deep-learning-based tool for noise reduction in astronomical
images. This package uses the native CoreML backend and includes the
executable and model packages together.

This is the recommended macOS lane for Apple Silicon.

Keep ./deepsnr, DeepSNR_weights_v1.mlpackage, and
DeepSNR_weights_v2.mlpackage together. The executable uses the bundled
weights next to itself by default. Use --model 1 or --model 2 to select a
bundled model; use --weights only to override the bundled model package. Do
not mix files from different DeepSNR packages.

Output paths are resolved relative to the current working directory unless
absolute.


Quick Start
-----------

Run the executable from the extracted package directory, or invoke it by
path from another working directory:

  ./deepsnr --input input.tif --output denoised.tif

Model 2 is the default and supports RGB and grayscale images. Model 1 is the
older model line and is intended for RGB images.


Options
-------

  -i, --input <file>
      Input image filename. Default: original.jpg.

  -o, --output <file>
      Denoised output image filename. Default: denoised.jpg.

  -m, --model <1|2>
      Select bundled model version 1 or 2 from the package directory.
      Default: 2. Model 2 supports RGB and grayscale images. Model 1 is
      the older model line and is intended for RGB images. This option is
      ignored when --weights is provided.

  -w, --weights <file>
      Override the bundled model package. Normally omit this option and use
      --model 1 or --model 2 to select DeepSNR_weights_v1.mlpackage or
      DeepSNR_weights_v2.mlpackage from the package directory.

  -s, --stride <int>
      Tile stride. Default: 480. The value must be even and no larger than
      the 512 pixel processing window.

  -q, --quiet
      Suppress progress output.

  -e, --eight
      Write TIFF and PNG output as 8-bit instead of the default 16-bit.


Short Option Clustering
-----------------------

Short boolean switches can be combined. For example, -eq is equivalent to
-e -q. Only switches without values can be clustered; options that take values,
such as -i, -o, -m, -w, and -s, must be provided separately.


Inputs And Outputs
------------------

Supported input sample depths are 8-bit and 16-bit integer images.
Unsupported input depths, including 32-bit floating-point images, are rejected.
Convert those images to 16-bit integer before running the CLI tool.

Supported inputs are grayscale or RGB/color images. Images with alpha channels
or other channel counts are rejected. Images must be at least 512x512 pixels.

TIFF and PNG output is written as a 16-bit integer image by default. Use
--eight to force 8-bit TIFF/PNG output. Other output formats are written as
8-bit images.

On first launch macOS may verify the notarized executable. If Gatekeeper blocks
execution, use the normal macOS security prompt to allow the application.


Legal
-----

The DeepSNR neural-network architecture is based on the NAFNet repository:

  https://github.com/megvii-research/NAFNet

See LICENSE.txt for the DeepSNR license. This package uses Apple's system
CoreML framework and does not redistribute CoreML runtime libraries.
