pyanime4k 3.1.0__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyanime4k/__init__.py +3 -0
- pyanime4k/info.py +13 -0
- pyanime4k/pyac/__init__.py +1 -0
- pyanime4k/pyac/pyac/__init__.pyi +7 -0
- pyanime4k/pyac/pyac/core.pyi +184 -0
- pyanime4k/pyac/pyac/specs.pyi +6 -0
- pyanime4k/pyac/pyac.cp310-win_amd64.pyd +0 -0
- pyanime4k/upscale.py +28 -0
- pyanime4k-3.1.0.dist-info/METADATA +122 -0
- pyanime4k-3.1.0.dist-info/RECORD +13 -0
- pyanime4k-3.1.0.dist-info/WHEEL +5 -0
- pyanime4k-3.1.0.dist-info/licenses/LICENSE +21 -0
- pyanime4k-3.1.0.dist-info/top_level.txt +2 -0
pyanime4k/__init__.py
ADDED
pyanime4k/info.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .pyac import pyac
|
|
2
|
+
|
|
3
|
+
def print_model_list():
|
|
4
|
+
for name, description in zip(pyac.specs.ModelNameList, pyac.specs.ModelDescriptionList):
|
|
5
|
+
print(f"{name}\t\t{description}")
|
|
6
|
+
|
|
7
|
+
def print_processor_list():
|
|
8
|
+
for name, description in zip(pyac.specs.ProcessorNameList, pyac.specs.ProcessorDescriptionList):
|
|
9
|
+
print(f"{name}\t\t{description}")
|
|
10
|
+
|
|
11
|
+
def print_device_list():
|
|
12
|
+
for info in pyac.core.Processor.InfoList:
|
|
13
|
+
print(info, end="")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .pyac.core import *
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import numpy
|
|
3
|
+
import numpy.typing
|
|
4
|
+
import typing
|
|
5
|
+
__all__: list[str] = ['IMREAD_COLOR', 'IMREAD_GRAYSCALE', 'IMREAD_RGB', 'IMREAD_RGBA', 'IMREAD_UNCHANGED', 'ImreadModes', 'Processor', 'RESIZE_BICUBIC_0_100', 'RESIZE_BICUBIC_0_60', 'RESIZE_BICUBIC_0_75', 'RESIZE_BICUBIC_20_50', 'RESIZE_BILINEAR', 'RESIZE_CATMULL_ROM', 'RESIZE_LANCZOS2', 'RESIZE_LANCZOS3', 'RESIZE_LANCZOS4', 'RESIZE_MITCHELL_NETRAVALI', 'RESIZE_POINT', 'RESIZE_SOFTCUBIC100', 'RESIZE_SOFTCUBIC50', 'RESIZE_SOFTCUBIC75', 'RESIZE_SPLINE16', 'RESIZE_SPLINE36', 'RESIZE_SPLINE64', 'ResizeModes', 'imread', 'imwrite', 'resize']
|
|
6
|
+
class ImreadModes:
|
|
7
|
+
"""
|
|
8
|
+
Members:
|
|
9
|
+
|
|
10
|
+
IMREAD_UNCHANGED
|
|
11
|
+
|
|
12
|
+
IMREAD_GRAYSCALE
|
|
13
|
+
|
|
14
|
+
IMREAD_COLOR
|
|
15
|
+
|
|
16
|
+
IMREAD_RGB
|
|
17
|
+
|
|
18
|
+
IMREAD_RGBA
|
|
19
|
+
"""
|
|
20
|
+
IMREAD_COLOR: typing.ClassVar[ImreadModes] # value = <ImreadModes.IMREAD_COLOR: 3>
|
|
21
|
+
IMREAD_GRAYSCALE: typing.ClassVar[ImreadModes] # value = <ImreadModes.IMREAD_GRAYSCALE: 1>
|
|
22
|
+
IMREAD_RGB: typing.ClassVar[ImreadModes] # value = <ImreadModes.IMREAD_COLOR: 3>
|
|
23
|
+
IMREAD_RGBA: typing.ClassVar[ImreadModes] # value = <ImreadModes.IMREAD_RGBA: 4>
|
|
24
|
+
IMREAD_UNCHANGED: typing.ClassVar[ImreadModes] # value = <ImreadModes.IMREAD_UNCHANGED: 0>
|
|
25
|
+
__members__: typing.ClassVar[dict[str, ImreadModes]] # value = {'IMREAD_UNCHANGED': <ImreadModes.IMREAD_UNCHANGED: 0>, 'IMREAD_GRAYSCALE': <ImreadModes.IMREAD_GRAYSCALE: 1>, 'IMREAD_COLOR': <ImreadModes.IMREAD_COLOR: 3>, 'IMREAD_RGB': <ImreadModes.IMREAD_COLOR: 3>, 'IMREAD_RGBA': <ImreadModes.IMREAD_RGBA: 4>}
|
|
26
|
+
def __eq__(self, other: typing.Any) -> bool:
|
|
27
|
+
...
|
|
28
|
+
def __getstate__(self) -> int:
|
|
29
|
+
...
|
|
30
|
+
def __hash__(self) -> int:
|
|
31
|
+
...
|
|
32
|
+
def __index__(self) -> int:
|
|
33
|
+
...
|
|
34
|
+
def __init__(self, value: typing.SupportsInt) -> None:
|
|
35
|
+
...
|
|
36
|
+
def __int__(self) -> int:
|
|
37
|
+
...
|
|
38
|
+
def __ne__(self, other: typing.Any) -> bool:
|
|
39
|
+
...
|
|
40
|
+
def __repr__(self) -> str:
|
|
41
|
+
...
|
|
42
|
+
def __setstate__(self, state: typing.SupportsInt) -> None:
|
|
43
|
+
...
|
|
44
|
+
def __str__(self) -> str:
|
|
45
|
+
...
|
|
46
|
+
@property
|
|
47
|
+
def name(self) -> str:
|
|
48
|
+
...
|
|
49
|
+
@property
|
|
50
|
+
def value(self) -> int:
|
|
51
|
+
...
|
|
52
|
+
class Processor:
|
|
53
|
+
CPU: typing.ClassVar[int] = 0
|
|
54
|
+
CUDA: typing.ClassVar[int] = 2
|
|
55
|
+
OpenCL: typing.ClassVar[int] = 1
|
|
56
|
+
InfoList: typing.ClassVar[tuple[str, ...]]
|
|
57
|
+
def __call__(self, src: numpy.ndarray, factor: typing.SupportsFloat = 2.0) -> numpy.ndarray:
|
|
58
|
+
...
|
|
59
|
+
@typing.overload
|
|
60
|
+
def __init__(self, processor_type: typing.SupportsInt = 0, device: typing.SupportsInt = 0, model: str = 'acnet-gan') -> None:
|
|
61
|
+
...
|
|
62
|
+
@typing.overload
|
|
63
|
+
def __init__(self, processor_type: str, device: typing.SupportsInt = 0, model: str = 'acnet-gan') -> None:
|
|
64
|
+
...
|
|
65
|
+
def __str__(self) -> str:
|
|
66
|
+
...
|
|
67
|
+
def error(self) -> str:
|
|
68
|
+
...
|
|
69
|
+
def name(self) -> str:
|
|
70
|
+
...
|
|
71
|
+
def ok(self) -> bool:
|
|
72
|
+
...
|
|
73
|
+
def process(self, src: numpy.ndarray, factor: typing.SupportsFloat = 2.0) -> numpy.ndarray:
|
|
74
|
+
...
|
|
75
|
+
class ResizeModes:
|
|
76
|
+
"""
|
|
77
|
+
Members:
|
|
78
|
+
|
|
79
|
+
RESIZE_POINT
|
|
80
|
+
|
|
81
|
+
RESIZE_CATMULL_ROM
|
|
82
|
+
|
|
83
|
+
RESIZE_MITCHELL_NETRAVALI
|
|
84
|
+
|
|
85
|
+
RESIZE_BICUBIC_0_60
|
|
86
|
+
|
|
87
|
+
RESIZE_BICUBIC_0_75
|
|
88
|
+
|
|
89
|
+
RESIZE_BICUBIC_0_100
|
|
90
|
+
|
|
91
|
+
RESIZE_BICUBIC_20_50
|
|
92
|
+
|
|
93
|
+
RESIZE_SOFTCUBIC50
|
|
94
|
+
|
|
95
|
+
RESIZE_SOFTCUBIC75
|
|
96
|
+
|
|
97
|
+
RESIZE_SOFTCUBIC100
|
|
98
|
+
|
|
99
|
+
RESIZE_LANCZOS2
|
|
100
|
+
|
|
101
|
+
RESIZE_LANCZOS3
|
|
102
|
+
|
|
103
|
+
RESIZE_LANCZOS4
|
|
104
|
+
|
|
105
|
+
RESIZE_SPLINE16
|
|
106
|
+
|
|
107
|
+
RESIZE_SPLINE36
|
|
108
|
+
|
|
109
|
+
RESIZE_SPLINE64
|
|
110
|
+
|
|
111
|
+
RESIZE_BILINEAR
|
|
112
|
+
"""
|
|
113
|
+
RESIZE_BICUBIC_0_100: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_BICUBIC_0_100: 5>
|
|
114
|
+
RESIZE_BICUBIC_0_60: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_BICUBIC_0_60: 3>
|
|
115
|
+
RESIZE_BICUBIC_0_75: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_BICUBIC_0_75: 4>
|
|
116
|
+
RESIZE_BICUBIC_20_50: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_BICUBIC_20_50: 6>
|
|
117
|
+
RESIZE_BILINEAR: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_BILINEAR: 16>
|
|
118
|
+
RESIZE_CATMULL_ROM: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_CATMULL_ROM: 1>
|
|
119
|
+
RESIZE_LANCZOS2: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_LANCZOS2: 10>
|
|
120
|
+
RESIZE_LANCZOS3: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_LANCZOS3: 11>
|
|
121
|
+
RESIZE_LANCZOS4: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_LANCZOS4: 12>
|
|
122
|
+
RESIZE_MITCHELL_NETRAVALI: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_MITCHELL_NETRAVALI: 2>
|
|
123
|
+
RESIZE_POINT: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_POINT: 0>
|
|
124
|
+
RESIZE_SOFTCUBIC100: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_SOFTCUBIC100: 9>
|
|
125
|
+
RESIZE_SOFTCUBIC50: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_SOFTCUBIC50: 7>
|
|
126
|
+
RESIZE_SOFTCUBIC75: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_SOFTCUBIC75: 8>
|
|
127
|
+
RESIZE_SPLINE16: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_SPLINE16: 13>
|
|
128
|
+
RESIZE_SPLINE36: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_SPLINE36: 14>
|
|
129
|
+
RESIZE_SPLINE64: typing.ClassVar[ResizeModes] # value = <ResizeModes.RESIZE_SPLINE64: 15>
|
|
130
|
+
__members__: typing.ClassVar[dict[str, ResizeModes]] # value = {'RESIZE_POINT': <ResizeModes.RESIZE_POINT: 0>, 'RESIZE_CATMULL_ROM': <ResizeModes.RESIZE_CATMULL_ROM: 1>, 'RESIZE_MITCHELL_NETRAVALI': <ResizeModes.RESIZE_MITCHELL_NETRAVALI: 2>, 'RESIZE_BICUBIC_0_60': <ResizeModes.RESIZE_BICUBIC_0_60: 3>, 'RESIZE_BICUBIC_0_75': <ResizeModes.RESIZE_BICUBIC_0_75: 4>, 'RESIZE_BICUBIC_0_100': <ResizeModes.RESIZE_BICUBIC_0_100: 5>, 'RESIZE_BICUBIC_20_50': <ResizeModes.RESIZE_BICUBIC_20_50: 6>, 'RESIZE_SOFTCUBIC50': <ResizeModes.RESIZE_SOFTCUBIC50: 7>, 'RESIZE_SOFTCUBIC75': <ResizeModes.RESIZE_SOFTCUBIC75: 8>, 'RESIZE_SOFTCUBIC100': <ResizeModes.RESIZE_SOFTCUBIC100: 9>, 'RESIZE_LANCZOS2': <ResizeModes.RESIZE_LANCZOS2: 10>, 'RESIZE_LANCZOS3': <ResizeModes.RESIZE_LANCZOS3: 11>, 'RESIZE_LANCZOS4': <ResizeModes.RESIZE_LANCZOS4: 12>, 'RESIZE_SPLINE16': <ResizeModes.RESIZE_SPLINE16: 13>, 'RESIZE_SPLINE36': <ResizeModes.RESIZE_SPLINE36: 14>, 'RESIZE_SPLINE64': <ResizeModes.RESIZE_SPLINE64: 15>, 'RESIZE_BILINEAR': <ResizeModes.RESIZE_BILINEAR: 16>}
|
|
131
|
+
def __eq__(self, other: typing.Any) -> bool:
|
|
132
|
+
...
|
|
133
|
+
def __getstate__(self) -> int:
|
|
134
|
+
...
|
|
135
|
+
def __hash__(self) -> int:
|
|
136
|
+
...
|
|
137
|
+
def __index__(self) -> int:
|
|
138
|
+
...
|
|
139
|
+
def __init__(self, value: typing.SupportsInt) -> None:
|
|
140
|
+
...
|
|
141
|
+
def __int__(self) -> int:
|
|
142
|
+
...
|
|
143
|
+
def __ne__(self, other: typing.Any) -> bool:
|
|
144
|
+
...
|
|
145
|
+
def __repr__(self) -> str:
|
|
146
|
+
...
|
|
147
|
+
def __setstate__(self, state: typing.SupportsInt) -> None:
|
|
148
|
+
...
|
|
149
|
+
def __str__(self) -> str:
|
|
150
|
+
...
|
|
151
|
+
@property
|
|
152
|
+
def name(self) -> str:
|
|
153
|
+
...
|
|
154
|
+
@property
|
|
155
|
+
def value(self) -> int:
|
|
156
|
+
...
|
|
157
|
+
def imread(filename: str, mode: ImreadModes = ...) -> numpy.typing.NDArray[numpy.uint8]:
|
|
158
|
+
...
|
|
159
|
+
def imwrite(filename: str, image: typing.Annotated[numpy.typing.ArrayLike, numpy.uint8]) -> bool:
|
|
160
|
+
...
|
|
161
|
+
def resize(src: numpy.ndarray, dsize: tuple, fx: typing.SupportsFloat = 0.0, fy: typing.SupportsFloat = 0.0, mode: ResizeModes = ...) -> numpy.ndarray:
|
|
162
|
+
...
|
|
163
|
+
IMREAD_COLOR: ImreadModes # value = <ImreadModes.IMREAD_COLOR: 3>
|
|
164
|
+
IMREAD_GRAYSCALE: ImreadModes # value = <ImreadModes.IMREAD_GRAYSCALE: 1>
|
|
165
|
+
IMREAD_RGB: ImreadModes # value = <ImreadModes.IMREAD_COLOR: 3>
|
|
166
|
+
IMREAD_RGBA: ImreadModes # value = <ImreadModes.IMREAD_RGBA: 4>
|
|
167
|
+
IMREAD_UNCHANGED: ImreadModes # value = <ImreadModes.IMREAD_UNCHANGED: 0>
|
|
168
|
+
RESIZE_BICUBIC_0_100: ResizeModes # value = <ResizeModes.RESIZE_BICUBIC_0_100: 5>
|
|
169
|
+
RESIZE_BICUBIC_0_60: ResizeModes # value = <ResizeModes.RESIZE_BICUBIC_0_60: 3>
|
|
170
|
+
RESIZE_BICUBIC_0_75: ResizeModes # value = <ResizeModes.RESIZE_BICUBIC_0_75: 4>
|
|
171
|
+
RESIZE_BICUBIC_20_50: ResizeModes # value = <ResizeModes.RESIZE_BICUBIC_20_50: 6>
|
|
172
|
+
RESIZE_BILINEAR: ResizeModes # value = <ResizeModes.RESIZE_BILINEAR: 16>
|
|
173
|
+
RESIZE_CATMULL_ROM: ResizeModes # value = <ResizeModes.RESIZE_CATMULL_ROM: 1>
|
|
174
|
+
RESIZE_LANCZOS2: ResizeModes # value = <ResizeModes.RESIZE_LANCZOS2: 10>
|
|
175
|
+
RESIZE_LANCZOS3: ResizeModes # value = <ResizeModes.RESIZE_LANCZOS3: 11>
|
|
176
|
+
RESIZE_LANCZOS4: ResizeModes # value = <ResizeModes.RESIZE_LANCZOS4: 12>
|
|
177
|
+
RESIZE_MITCHELL_NETRAVALI: ResizeModes # value = <ResizeModes.RESIZE_MITCHELL_NETRAVALI: 2>
|
|
178
|
+
RESIZE_POINT: ResizeModes # value = <ResizeModes.RESIZE_POINT: 0>
|
|
179
|
+
RESIZE_SOFTCUBIC100: ResizeModes # value = <ResizeModes.RESIZE_SOFTCUBIC100: 9>
|
|
180
|
+
RESIZE_SOFTCUBIC50: ResizeModes # value = <ResizeModes.RESIZE_SOFTCUBIC50: 7>
|
|
181
|
+
RESIZE_SOFTCUBIC75: ResizeModes # value = <ResizeModes.RESIZE_SOFTCUBIC75: 8>
|
|
182
|
+
RESIZE_SPLINE16: ResizeModes # value = <ResizeModes.RESIZE_SPLINE16: 13>
|
|
183
|
+
RESIZE_SPLINE36: ResizeModes # value = <ResizeModes.RESIZE_SPLINE36: 14>
|
|
184
|
+
RESIZE_SPLINE64: ResizeModes # value = <ResizeModes.RESIZE_SPLINE64: 15>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
__all__: list[str] = ['ModelDescriptionList', 'ModelNameList', 'ProcessorDescriptionList', 'ProcessorNameList']
|
|
3
|
+
ModelDescriptionList: tuple = ('Lightweight CNN, detail enhancement.', 'Lightweight CNN, mild denoising.', 'Lightweight CNN, moderate denoising.', 'Lightweight CNN, heavy denoising.', 'Lightweight CNN, extreme denoising.', 'Lightweight ResNet, mild denoising.')
|
|
4
|
+
ModelNameList: tuple = ('acnet-gan', 'acnet-hdn0', 'acnet-hdn1', 'acnet-hdn2', 'acnet-hdn3', 'arnet-hdn')
|
|
5
|
+
ProcessorDescriptionList: tuple = ('General-purpose CPU processing with optional SIMD acceleration.', 'Cross-platform acceleration requiring OpenCL 1.2+ compliant devices.', 'NVIDIA GPU acceleration requiring Compute Capability 5.0+.')
|
|
6
|
+
ProcessorNameList: tuple = ('cpu', 'opencl', 'cuda')
|
|
Binary file
|
pyanime4k/upscale.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from itertools import zip_longest, islice
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from .pyac import pyac
|
|
5
|
+
|
|
6
|
+
def upscale_images(
|
|
7
|
+
inputs: list,
|
|
8
|
+
outputs: list = [],
|
|
9
|
+
output_suffix: str = "_output",
|
|
10
|
+
factor: float = 2.0,
|
|
11
|
+
processor_type: str = "cpu",
|
|
12
|
+
device_id:int = 0,
|
|
13
|
+
model_name: str = "acnet-hdn0"
|
|
14
|
+
):
|
|
15
|
+
if isinstance(inputs, str):
|
|
16
|
+
inputs = [inputs]
|
|
17
|
+
|
|
18
|
+
processor = pyac.core.Processor(processor_type, device_id, model_name)
|
|
19
|
+
|
|
20
|
+
for input, output in islice(zip_longest(inputs, outputs, fillvalue=None), len(inputs)):
|
|
21
|
+
if output is None:
|
|
22
|
+
input_path = Path(input)
|
|
23
|
+
output = input_path.with_stem(input_path.stem + output_suffix)
|
|
24
|
+
|
|
25
|
+
src = pyac.core.imread(str(input))
|
|
26
|
+
dst = processor(src, factor)
|
|
27
|
+
if not pyac.core.imwrite(str(output), dst):
|
|
28
|
+
raise IOError(f"Failed to save image to {output}")
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyanime4k
|
|
3
|
+
Version: 3.1.0
|
|
4
|
+
License: MIT
|
|
5
|
+
Classifier: Programming Language :: Python :: 3
|
|
6
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
7
|
+
Classifier: Operating System :: MacOS
|
|
8
|
+
Classifier: Operating System :: POSIX
|
|
9
|
+
Classifier: Operating System :: Unix
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# PyAnime4K
|
|
17
|
+
|
|
18
|
+
PyAnime4K is a high performance anime image upscaler based on [Anime4KCPP](https://github.com/TianZerL/Anime4KCPP).
|
|
19
|
+
|
|
20
|
+
# Install
|
|
21
|
+
PyAnime4K can be installed easily through pip.
|
|
22
|
+
```shell
|
|
23
|
+
pip install pyanime4k
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
You can also build the wheel by yourself.
|
|
27
|
+
```shell
|
|
28
|
+
# sudo apt install ocl-icd-opencl-dev cmake build-essential
|
|
29
|
+
get clone --recurse-submodules https://github.com/TianZerL/pyanime4k.git
|
|
30
|
+
cd pyanime4k
|
|
31
|
+
pip install scikit-build
|
|
32
|
+
python setup.py bdist_wheel
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
# Usages
|
|
36
|
+
## Printing Info
|
|
37
|
+
```python
|
|
38
|
+
import pyanime4k
|
|
39
|
+
|
|
40
|
+
# Print supported model
|
|
41
|
+
pyanime4k.print_model_list()
|
|
42
|
+
|
|
43
|
+
# Print supported processor
|
|
44
|
+
pyanime4k.print_processor_list()
|
|
45
|
+
|
|
46
|
+
# Print supported devices for image processing
|
|
47
|
+
pyanime4k.print_device_list()
|
|
48
|
+
```
|
|
49
|
+
## Upscaling Images
|
|
50
|
+
```python
|
|
51
|
+
import pyanime4k
|
|
52
|
+
|
|
53
|
+
# with OpenCL acceleration, if possible
|
|
54
|
+
processor_type = "opencl"
|
|
55
|
+
|
|
56
|
+
# upscale a single image
|
|
57
|
+
pyanime4k.upscale_images("image1.png", processor_type = processor_type)
|
|
58
|
+
|
|
59
|
+
# upscale a list of images
|
|
60
|
+
pyanime4k.upscale_images(["image1.png", "image2.png"], processor_type = processor_type)
|
|
61
|
+
```
|
|
62
|
+
## Manual Upscaling
|
|
63
|
+
```python
|
|
64
|
+
import pyanime4k
|
|
65
|
+
|
|
66
|
+
# Create a processor
|
|
67
|
+
processor = pyanime4k.Processor(
|
|
68
|
+
processor_type="cpu",
|
|
69
|
+
device=0,
|
|
70
|
+
model="acnet-hdn0"
|
|
71
|
+
)
|
|
72
|
+
# Print processor info
|
|
73
|
+
print(processor)
|
|
74
|
+
# Read an image
|
|
75
|
+
src = pyanime4k.imread("image1.png")
|
|
76
|
+
# Process it
|
|
77
|
+
dst = processor(src=src, factor=2.0)
|
|
78
|
+
# Write to disk
|
|
79
|
+
pyanime4k.imwrite("image1_outout.png", dst)
|
|
80
|
+
```
|
|
81
|
+
## OpenCV
|
|
82
|
+
``` Python
|
|
83
|
+
import cv2, pyanime4k
|
|
84
|
+
|
|
85
|
+
img = cv2.imread("image.png")
|
|
86
|
+
|
|
87
|
+
processor = pyanime4k.Processor(
|
|
88
|
+
processor_type="cpu",
|
|
89
|
+
device=0,
|
|
90
|
+
model="acnet-hdn0"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# opencv load image as BGR, but we need an RGB image
|
|
94
|
+
src = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
|
95
|
+
|
|
96
|
+
dst = processor(src)
|
|
97
|
+
|
|
98
|
+
img = cv2.cvtColor(dst, cv2.COLOR_RGB2BGR)
|
|
99
|
+
|
|
100
|
+
cv2.imshow("pyanime4k", img)
|
|
101
|
+
cv2.waitKey()
|
|
102
|
+
```
|
|
103
|
+
## Pillow
|
|
104
|
+
```python
|
|
105
|
+
from PIL import Image
|
|
106
|
+
import numpy, pyanime4k
|
|
107
|
+
|
|
108
|
+
img = Image.open("D:/temp/p1.png")
|
|
109
|
+
|
|
110
|
+
processor = pyanime4k.Processor(
|
|
111
|
+
processor_type="cpu",
|
|
112
|
+
device=0,
|
|
113
|
+
model="acnet-hdn0"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# We need a numpy array
|
|
117
|
+
src = numpy.asarray(img)
|
|
118
|
+
dst = processor(src)
|
|
119
|
+
img = Image.fromarray(dst)
|
|
120
|
+
|
|
121
|
+
img.show()
|
|
122
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
pyanime4k/__init__.py,sha256=OYVRiJgxr163XyjVRh1x5ZNX1UOZHBv9GDBOp9buj64,66
|
|
2
|
+
pyanime4k/info.py,sha256=ZgSahqzqxSR_lrXQAi3rOZhO4lLorasp5NfaqV5uljY,468
|
|
3
|
+
pyanime4k/upscale.py,sha256=GoH2oh8fYX5TdIfDCBEB-xxsf_3xAH_ARam11hzrxUA,899
|
|
4
|
+
pyanime4k/pyac/__init__.py,sha256=OoffRsy0diunqy8QzvD9WhSxcGhbfzD499PghpbLRs0,26
|
|
5
|
+
pyanime4k/pyac/pyac.cp310-win_amd64.pyd,sha256=UnLLYF2KD4M9kqyuhSMe7yrYpCnRjGGfyVkGO4c7DFI,2248192
|
|
6
|
+
pyanime4k/pyac/pyac/__init__.pyi,sha256=CBaI96ey60K1GjfSjj4VksuUpc7NbtcYFcRiGU5SJuk,175
|
|
7
|
+
pyanime4k/pyac/pyac/core.pyi,sha256=SKu1Pt4wFyoQZ1TeEvNNEE_FI8pTL6bwcw6HO3Sel6Y,9187
|
|
8
|
+
pyanime4k/pyac/pyac/specs.pyi,sha256=YoNQA6yXEglvAsaJixnXVIB4irLusAqnRfMUaoHLQ9c,810
|
|
9
|
+
pyanime4k-3.1.0.dist-info/licenses/LICENSE,sha256=Y1LqP77JBqrXWO4jJ_2bg6N-hHoU_JGgxQnYqxw1f3U,1085
|
|
10
|
+
pyanime4k-3.1.0.dist-info/METADATA,sha256=rr_b8UkJn-z0jpmN6vAffKLYqlGhOYQqWPkKp_wCwF8,2665
|
|
11
|
+
pyanime4k-3.1.0.dist-info/WHEEL,sha256=grXnj_hjz9AcJWnDGoMAyy0X5GgALMAtIvNbRMBzgmk,96
|
|
12
|
+
pyanime4k-3.1.0.dist-info/top_level.txt,sha256=KxVm1dNU5ew2loJ2VSTl_3lkuv8_VWFpd0xSjcTtLqA,21
|
|
13
|
+
pyanime4k-3.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 TianZer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|