Skip to content

Commit

Permalink
rel 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
FredHappyface committed Feb 3, 2024
1 parent 8be0e4a commit d479efa
Show file tree
Hide file tree
Showing 32 changed files with 830 additions and 381 deletions.
57 changes: 31 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
repos:
- repo: https://github.com/FHPythonUtils/Blackt
rev: '2022.0.3'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: blackt
- id: ruff
args: [ --fix ]

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.347
hooks:
- id: pyright

- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/FHPythonUtils/Blackt
rev: '2024.0.1'
hooks:
- id: isort
- id: blackt

- repo: https://github.com/pycqa/pylint
rev: v3.0.0a6
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
rev: v1.3.2
hooks:
- id: pylint
exclude: "tests/"
args: [--disable=import-error,--jobs=0]
- id: python-safety-dependencies-check
files: pyproject.toml

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: "tests/"
- id: end-of-file-fixer
exclude: "tests/"
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: detect-private-key
- id: mixed-line-ending

- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/boidolr/pre-commit-images
rev: v1.2.1
rev: v1.5.1
hooks:
- id: optimize-avif
exclude: "tests/"
- id: optimize-jpg
exclude: "tests/"
- id: optimize-png
exclude: "tests/"
- id: optimize-svg
exclude: "tests/"
- id: optimize-webp
exclude: "tests/"

exclude: "tests/data|documentation/reference"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
All major and minor version changes will be documented in this file. Details of
patch-level version changes can be found in [commit messages](../../commits/master).

## 2024 - 2024/02/03

- use ruff instead of pylint
- code quality improvements

## 2023 - 2023/06/26

- Improved the tutorial docs
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@

<img src="readme-assets/icons/name.png" alt="Project Icon" width="750">

Chainer implementation of waifu2x.
Waifu2x is an image upscaling and noise reduction algorithm that gained
popularity for its ability to enhance the quality of anime-style images. The
implementation in Chainer, a deep learning framework, uses neural networks
to perform the image enhancement tasks.


## Help

Expand Down
82 changes: 72 additions & 10 deletions documentation/reference/waifu2x/data_augmentation.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Data Augmentation

[Waifu2x Index](../README.md#waifu2x-index) /
[Waifu2x](./index.md#waifu2x) /
Data Augmentation
[Waifu2x Index](../README.md#waifu2x-index) / [Waifu2x](./index.md#waifu2x) / Data Augmentation

> Auto-generated documentation for [waifu2x.data_augmentation](../../../waifu2x/data_augmentation.py) module.
Expand All @@ -15,19 +13,45 @@ Data Augmentation

## color_noise

[Show source in data_augmentation.py:22](../../../waifu2x/data_augmentation.py#L22)
[Show source in data_augmentation.py:48](../../../waifu2x/data_augmentation.py#L48)

Apply color noise to the input image array.

#### Arguments

----
- `src` *np.ndarray* - Input image array.
- `p` *float* - Probability of applying the noise.
- `factor` *float* - Noise factor.

#### Returns

-------
- `np.ndarray` - Processed image array.

#### Signature

```python
def color_noise(src: np.ndarray, p, factor: float = 0.1) -> np.ndarray: ...
def color_noise(src: np.ndarray, p: float, factor: float = 0.1) -> np.ndarray: ...
```



## flip

[Show source in data_augmentation.py:33](../../../waifu2x/data_augmentation.py#L33)
[Show source in data_augmentation.py:73](../../../waifu2x/data_augmentation.py#L73)

Flip the input image array.

#### Arguments

----
- `src` *np.ndarray* - Input image array.

#### Returns

-------
- `np.ndarray` - Processed image array.

#### Signature

Expand All @@ -39,7 +63,20 @@ def flip(src: np.ndarray) -> np.ndarray: ...

## half

[Show source in data_augmentation.py:45](../../../waifu2x/data_augmentation.py#L45)
[Show source in data_augmentation.py:97](../../../waifu2x/data_augmentation.py#L97)

Scale down the input image array by half.

#### Arguments

----
- `src` *np.ndarray* - Input image array.
- `p` *np.ndarray* - Probability array.

#### Returns

-------
- `np.ndarray` - Processed image array.

#### Signature

Expand All @@ -51,7 +88,19 @@ def half(src: np.ndarray, p: np.ndarray) -> np.ndarray: ...

## shift_1px

[Show source in data_augmentation.py:54](../../../waifu2x/data_augmentation.py#L54)
[Show source in data_augmentation.py:117](../../../waifu2x/data_augmentation.py#L117)

Shift the input image array by 1 pixel.

#### Arguments

----
- src (np.ndarray): Input image array.

#### Returns

-------
- `-` *np.ndarray* - Shifted image array.

#### Signature

Expand All @@ -63,10 +112,23 @@ def shift_1px(src: np.ndarray) -> np.ndarray: ...

## unsharp_mask

[Show source in data_augmentation.py:11](../../../waifu2x/data_augmentation.py#L11)
[Show source in data_augmentation.py:26](../../../waifu2x/data_augmentation.py#L26)

Apply unsharp mask filter to the input image array.

#### Arguments

----
- `src` *np.ndarray* - Input image array.
- `p` *float* - Probability of applying the filter.

#### Returns

-------
- `np.ndarray` - Processed image array.

#### Signature

```python
def unsharp_mask(src: np.ndarray, p) -> np.ndarray: ...
def unsharp_mask(src: np.ndarray, p: float) -> np.ndarray: ...
```
97 changes: 85 additions & 12 deletions documentation/reference/waifu2x/dataset_sampler.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,89 @@
# DatasetSampler

[Waifu2x Index](../README.md#waifu2x-index) /
[Waifu2x](./index.md#waifu2x) /
DatasetSampler
[Waifu2x Index](../README.md#waifu2x-index) / [Waifu2x](./index.md#waifu2x) / DatasetSampler

> Auto-generated documentation for [waifu2x.dataset_sampler](../../../waifu2x/dataset_sampler.py) module.
- [DatasetSampler](#datasetsampler)
- [DatasetSampler](#datasetsampler-1)
- [DatasetSampler()._init_process](#datasetsampler()_init_process)
- [DatasetSampler().finalize](#datasetsampler()finalize)
- [DatasetSampler().get](#datasetsampler()get)
- [DatasetSampler().reload_switch](#datasetsampler()reload_switch)
- [DatasetSampler().wait](#datasetsampler()wait)
- [_worker](#_worker)

## DatasetSampler

[Show source in dataset_sampler.py:14](../../../waifu2x/dataset_sampler.py#L14)
[Show source in dataset_sampler.py:32](../../../waifu2x/dataset_sampler.py#L32)

Class for sampling datasets for training or testing purposes.

#### Arguments

----
- `filelist` *list[str]* - List of file paths.
- `config` *argparse.Namespace* - Configuration settings.

#### Attributes

----------
- `filelist` *list[str]* - List of file paths.
- `config` *argparse.Namespace* - Configuration settings.
- `worker` *multiprocessing.Process* - Worker process.
- `dataset` *tuple* - Dataset containing input and output arrays.
- `cache_name` *str* - Name of the cached file.
- `_queue` *multiprocessing.Queue* - Communication queue.
- `_finalized` *multiprocessing.Event* - Event for finalizing the process.
- `_init` *bool* - Flag indicating initialization status.
- `_reload` *bool* - Flag indicating whether to reload the dataset.
- `_running` *bool* - Flag indicating whether the process is running.

#### Methods

-------
- `finalize()` - Finalizes the dataset sampling process.
- `reload_switch(init` - bool = True): Switches the reload state.
- `_init_process()` - Initializes the sampling process.
- `wait()` - Waits for the process to complete.
- `get()` - Retrieves the dataset.

#### Signature

```python
class DatasetSampler:
def __init__(self, filelist, config): ...
def __init__(self, filelist: list[str], config: argparse.Namespace) -> None: ...
```

### DatasetSampler()._init_process

[Show source in dataset_sampler.py:104](../../../waifu2x/dataset_sampler.py#L104)

Initialize the sampling process.

#### Signature

```python
def _init_process(self) -> None: ...
```

### DatasetSampler().finalize

[Show source in dataset_sampler.py:33](../../../waifu2x/dataset_sampler.py#L33)
[Show source in dataset_sampler.py:91](../../../waifu2x/dataset_sampler.py#L91)

Finalize the dataset sampling process.

#### Signature

```python
def finalize(self): ...
def finalize(self) -> None: ...
```

### DatasetSampler().get

[Show source in dataset_sampler.py:59](../../../waifu2x/dataset_sampler.py#L59)
[Show source in dataset_sampler.py:121](../../../waifu2x/dataset_sampler.py#L121)

Retrieve the dataset.

#### Signature

Expand All @@ -46,20 +93,46 @@ def get(self): ...

### DatasetSampler().reload_switch

[Show source in dataset_sampler.py:40](../../../waifu2x/dataset_sampler.py#L40)
[Show source in dataset_sampler.py:99](../../../waifu2x/dataset_sampler.py#L99)

Switches the reload state.

#### Signature

```python
def reload_switch(self, init: bool = True): ...
def reload_switch(self, init: bool = True) -> None: ...
```

### DatasetSampler().wait

[Show source in dataset_sampler.py:53](../../../waifu2x/dataset_sampler.py#L53)
[Show source in dataset_sampler.py:114](../../../waifu2x/dataset_sampler.py#L114)

Wait for the process to complete.

#### Signature

```python
def wait(self) -> None: ...
```



## _worker

[Show source in dataset_sampler.py:138](../../../waifu2x/dataset_sampler.py#L138)

Worker function for dataset sampling.

#### Arguments

----
- `filelist` *list[str]* - List of file paths.
- `args` *argparse.Namespace* - Command-line arguments.
- `queue` *multiprocessing.Queue* - Communication queue.
- `finalized` *multiprocessing.Event* - Event for finalizing the process.

#### Signature

```python
def wait(self): ...
def _worker(filelist: list[str], args: argparse.Namespace, queue, finalized) -> None: ...
```
Loading

0 comments on commit d479efa

Please sign in to comment.