π Technical docsο
The classes of neuralde are simple to use. Create an instance and apply the method transform()
.
The prediction methods from the documentations ensures the
compliance of models from various ML/DL libraries (such as Keras and scikit-learn) to neuralde.
- class neural_de.transformations.transformation.BaseTransformation(logger=None)[source]
Parent class for any transformation methods of the library. Provides the methods for logging and input validation.
- Parameters:
logger (
Optional
[Logger
]) β logging.logger. It is recommended to use the Confiance one, obtainable with neural_de.utils.get_logger(β¦)
- class neural_de.transformations.brightness_enhancer.BrightnessEnhancer(logger=None)[source]
BaseTransformation method for image brightness change. It uses NPLIE-based method for brightness enhancement, and Opencv for transforming the image.
Example :
See the notebook examples/BrightnessEnhancer_example.ipynb for more usage details.
1- Import the class
. code-block:: python
from neural_de.transformations import BrightnessEnhancer
2- Create an instance of BrightnessEnhancer.
. code-block:: python
bright_ehn = BrightnessEnhancer()
3- Apply the brightness change to a batch of images to a given shape
. code-block:: python
out_images = bright_ehn.transform(images)
- Parameters:
logger (
Optional
[Logger
]) β It is recommended to use the Confiance logger, obtainable withneural_de.utils.get_logger β
None (If) β
provided. (one logging with stdout will be) β
- class neural_de.transformations.centered_zoom.CenteredZoom(keep_ratio, logger=None)[source]
CenteredZoom image transformation based on a numpy implementation. Given a batch of 3-channels image of size width x height, return the centered tile of size width*keep_ratio x height*keep_ratio. This transformation does not perform any resolution enhancement of the returned content. See ResolutionEnhancer to perform both crop and resolution enhancement.
- Parameters:
keep_ratio (
float
) β The proportion of the input image we keep. Must be in ]0,1[.logger (
Optional
[Logger
]) β It is recommended to use the Confiance logger, obtainable with neural_de.utils.get_logger(β¦). If None, one logging with stdout will be provided.
- class neural_de.transformations.de_rain_enhancer.DeRainEnhancer(device='cpu', logger=None)[source]
Provides a rain removal image transformation using the GT-Rain Derain Model.
- Parameters:
device (
str
) β Any torch-compatible device string.logger (
Optional
[Logger
]) β It is recommended to use the Confiance logger, obtainable with neural_de.utils.get_logger(β¦). If None, one logging with stdout will be provided.
- class neural_de.transformations.de_snow_enhancer.DeSnowEnhancer(device='cpu', logger=None)[source]
Snow Removal Enhancer, Prenet based implementation.
** WARNING ** : The current method may have bad results on real images. The model had been trained on a simulated dataset, thus if the dataset is so different of the trained dataset, the results are not guaranteed.
- Parameters:
device β Any torch-compatible device string.
logger β It is recommended to use the Confiance logger, obtainable with neural_de.utils.get_logger(β¦). If None, one logging with stdout will be provided.
- class neural_de.transformations.kernel_deblurring_enhancer.KernelDeblurringEnhancer(kernel='high', custom_kernel=None, logger=None)[source]
Kernel Deblurring image transformation based on OpenCv implementation. Provides pre-set filter of medium and high intensity.
- Parameters:
kernel (
str
) βhigh
ormedium
: use a pre-set kernel with high or medium intensity.custom β Optional, custom kernel to use. It can be any non empty 2D matrix. If provided, the value of kernel will not be used.
logger (
Optional
[Logger
]) β It is recommended to use the Confiance logger, obtainable with neural_de.utils.get_logger(β¦). If None, one logging with stdout will be provided.
- class neural_de.transformations.night_image_enhancer.NightImageEnhancer(device='cpu', logger=None)[source]
Provides Night to Day image transformation using the MAXIM model.
- Parameters:
logger (
Optional
[Logger
]) β It is recommended to use the Confiance logger, obtainable with neural_de.utils.get_logger(β¦). If None, one logging with stdout will be provided.
- class neural_de.transformations.resolution_enhancer.ResolutionEnhancer(device='cpu', logger=None)[source]
BaseTransformation method for image resolution change. It uses neural-based method for resolution enhancement, and Opencv for diminishing the resolution.
- Example :
See the notebook examples/ResolutionEnhancer_example.ipynb for more usage details.
1- Import the class
from neural_de.transformations import ResolutionEnhancer
2- Create an instance of ResolutionEnhancer.
device ="Cuda"
is recommended if you have a gpu and torch with cuda enabled.res_shift = ResolutionEnhancer(device= "cpu")
3- Apply the resolution change to a batch of images to a given shape
out_images = res_shift.transform(images, ratio=2)
- Parameters:
device (
str
) β Any torch-compatible device string.logger (
Optional
[Logger
]) β It is recommended to use the Confiance logger, obtainable with neural_de.utils.get_logger(β¦). If None, one logging with stdout will be provided.
- class neural_de.transformations.transformation_pipeline.TransformationPipeline(config, logger=None)[source]
Provides a pipeline object, to facilitate the automation of multiple transformations methods, and/or offer loading from a yaml file.
You can check the example notebook examples/Pipeline_example.ipynb for details on the syntax and usage. An example of valid config file can be found in examples/config/conf_user.yaml
- Parameters:
config (
Union
[str
,list
,Path
]) β either a path toward a yaml configuration file, or a list of dict.logger (
Optional
[Logger
]) β It is recommended to use the confiance.ai logger, obtainable with neural_de.utils.get_logger(β¦). If None, one logging with stdout will be provided.
- class neural_de.transformations.diffusion.diffusion_enhancer.DiffusionEnhancer(device=None, config=DiffPureConfig(weights_path=PosixPath('/home/runner/.neuralde/diffpure/256x256_diffusion_uncond.pt'), img_shape=(3, 256, 256), attention_resolutions=[32, 16, 8], num_classes=None, dims=2, learn_sigma=True, num_channels=256, num_head_channels=64, num_res_blocks=2, resblock_updown=True, use_fp16=True, use_scale_shift_norm=True, num_heads=4, num_heads_upsample=-1, channel_mult=None, dropout=0.0, use_new_attention_order=False, t=150, t_delta=15, use_bm=False, use_checkpoint=False, conv_resample=True, sample_step=1, rand_t=False), logger=None)[source]
The goal of this class is to purify a batch of images, to reduce noise and to increase robustness against potential adversarial attacks contained in the images. The weights given in this librairy are adapted for an output in 256*256 format. Of course, all sizes are supported in input but the enhancer will resize the images to 256*256.
- Parameters:
device (
Optional
[DeviceObjType
]) β some steps can be computed with cpu but a gpu is highly recommended.config (
Optional
[DiffPureConfig
]) β an instance of the DiffPureConfig class. The most important attributes are: t, sample_step and t_delta. Higher t or sample step will lead to a stronger denoising, at the cost of processing time. t_delta is the quantity of noise added by the method before itβs diffusion process : the higher, the higher the chances to remove adversarial attacks, at the cost of a potentiel loss of quality in the images. The other attributes of DiffPureConfig should be modified for a custom Diffusion model.