prpy 0.2.2__py3-none-any.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.
- prpy/__init__.py +19 -0
- prpy/constants.py +24 -0
- prpy/ffmpeg/__init__.py +19 -0
- prpy/ffmpeg/probe.py +86 -0
- prpy/ffmpeg/readwrite.py +412 -0
- prpy/ffmpeg/utils.py +81 -0
- prpy/numpy/__init__.py +19 -0
- prpy/numpy/face.py +213 -0
- prpy/numpy/image.py +141 -0
- prpy/numpy/metric.py +179 -0
- prpy/numpy/signal.py +649 -0
- prpy/numpy/stride_tricks.py +182 -0
- prpy/tensorflow/__init__.py +19 -0
- prpy/tensorflow/image.py +203 -0
- prpy/tensorflow/loss.py +104 -0
- prpy/tensorflow/lr_schedule.py +74 -0
- prpy/tensorflow/model_saver.py +203 -0
- prpy/tensorflow/nan.py +226 -0
- prpy/tensorflow/optimizer.py +233 -0
- prpy/tensorflow/signal.py +103 -0
- prpy/torch/__init__.py +19 -0
- prpy/torch/model_saver.py +208 -0
- prpy-0.2.2.dist-info/LICENSE +19 -0
- prpy-0.2.2.dist-info/METADATA +75 -0
- prpy-0.2.2.dist-info/RECORD +27 -0
- prpy-0.2.2.dist-info/WHEEL +5 -0
- prpy-0.2.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Copyright (c) 2024 Philipp Rouast
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
# furnished to do so, subject to the following conditions:
|
|
9
|
+
#
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
# copies or substantial portions of the Software.
|
|
12
|
+
#
|
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
# SOFTWARE.
|
|
20
|
+
|
|
21
|
+
import tensorflow as tf
|
|
22
|
+
from typing import Union
|
|
23
|
+
|
|
24
|
+
def normalize(
|
|
25
|
+
x: Union[tf.Tensor, list],
|
|
26
|
+
axis: Union[int, tuple, None] = -1
|
|
27
|
+
) -> tf.Tensor:
|
|
28
|
+
"""Perform normalization
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
x: The input data
|
|
32
|
+
axis: Axis over which to normalize
|
|
33
|
+
Returns:
|
|
34
|
+
x: The normalized data
|
|
35
|
+
"""
|
|
36
|
+
assert isinstance(x, (tf.Tensor, list))
|
|
37
|
+
assert axis is None or isinstance(axis, (int, tuple))
|
|
38
|
+
# Convert to tf.Tensor if necessary
|
|
39
|
+
if not tf.is_tensor(x):
|
|
40
|
+
x = tf.convert_to_tensor(x)
|
|
41
|
+
mean = tf.math.reduce_mean(x, axis=axis, keepdims=True)
|
|
42
|
+
return x - mean
|
|
43
|
+
|
|
44
|
+
def scale(
|
|
45
|
+
x: Union[tf.Tensor, list],
|
|
46
|
+
axis: Union[int, tuple, None] = -1
|
|
47
|
+
) -> tf.Tensor:
|
|
48
|
+
"""Perform scaling
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
x: The input data
|
|
52
|
+
axis: Axis over which to scale
|
|
53
|
+
Returns:
|
|
54
|
+
x: The scaled data
|
|
55
|
+
"""
|
|
56
|
+
assert isinstance(x, (tf.Tensor, list))
|
|
57
|
+
assert axis is None or isinstance(axis, (int, tuple))
|
|
58
|
+
# Convert to tf.Tensor if necessary
|
|
59
|
+
if not tf.is_tensor(x):
|
|
60
|
+
x = tf.convert_to_tensor(x)
|
|
61
|
+
std = tf.math.reduce_std(x, axis=axis, keepdims=True)
|
|
62
|
+
return tf.math.divide_no_nan(x, std)
|
|
63
|
+
|
|
64
|
+
def standardize(
|
|
65
|
+
x: Union[tf.Tensor, list],
|
|
66
|
+
axis: Union[int, tuple, None] = -1
|
|
67
|
+
) -> tf.Tensor:
|
|
68
|
+
"""Perform standardization
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
x: The input data
|
|
72
|
+
axis: Axis over which to standardize
|
|
73
|
+
Returns:
|
|
74
|
+
x: The standardized data
|
|
75
|
+
"""
|
|
76
|
+
assert isinstance(x, (tf.Tensor, list))
|
|
77
|
+
assert axis is None or isinstance(axis, (int, tuple))
|
|
78
|
+
# Convert to tf.Tensor if necessary
|
|
79
|
+
if not tf.is_tensor(x):
|
|
80
|
+
x = tf.convert_to_tensor(x)
|
|
81
|
+
mean = tf.math.reduce_mean(x, axis=axis, keepdims=True)
|
|
82
|
+
std = tf.math.reduce_std(x, axis=axis, keepdims=True)
|
|
83
|
+
return tf.math.divide_no_nan(x - mean, std)
|
|
84
|
+
|
|
85
|
+
def diff(
|
|
86
|
+
x: Union[tf.Tensor, list],
|
|
87
|
+
axis: int = 0):
|
|
88
|
+
"""Compute first signal difference.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
x: The signal
|
|
92
|
+
axis: Scalar, the dimension across which to calculate diff.
|
|
93
|
+
Returns:
|
|
94
|
+
y: The diff signal
|
|
95
|
+
"""
|
|
96
|
+
assert isinstance(x, (tf.Tensor, list))
|
|
97
|
+
# Convert to tf.Tensor if necessary
|
|
98
|
+
if not tf.is_tensor(x):
|
|
99
|
+
x = tf.convert_to_tensor(x)
|
|
100
|
+
assert axis==0 or axis==1, "Only axis=0 or axis=1 supported"
|
|
101
|
+
return tf.cond(tf.equal(axis, 0),
|
|
102
|
+
true_fn=lambda: x[1:] - x[:-1],
|
|
103
|
+
false_fn=lambda: x[:,1:] - x[:,:-1])
|
prpy/torch/__init__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Copyright (c) 2024 Philipp Rouast
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
# furnished to do so, subject to the following conditions:
|
|
9
|
+
#
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
# copies or substantial portions of the Software.
|
|
12
|
+
#
|
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
# SOFTWARE.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Copyright (c) 2024 Philipp Rouast
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
# furnished to do so, subject to the following conditions:
|
|
9
|
+
#
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
# copies or substantial portions of the Software.
|
|
12
|
+
#
|
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
# SOFTWARE.
|
|
20
|
+
|
|
21
|
+
"""Save the best models"""
|
|
22
|
+
|
|
23
|
+
import glob
|
|
24
|
+
import logging
|
|
25
|
+
import os
|
|
26
|
+
import torch
|
|
27
|
+
from typing import Union, Callable, Tuple
|
|
28
|
+
|
|
29
|
+
class Candidate(object):
|
|
30
|
+
"""A candidate model with a score"""
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
score: Union[float, int],
|
|
34
|
+
dir: str,
|
|
35
|
+
filename: str
|
|
36
|
+
):
|
|
37
|
+
"""Initialise a new candidate.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
score: The score achieved by the candidate
|
|
41
|
+
dir: The directory where the candidate model can be saved
|
|
42
|
+
filename: The filename under which the candidate model can be saved
|
|
43
|
+
"""
|
|
44
|
+
assert isinstance(score, (float, int))
|
|
45
|
+
assert isinstance(dir, str)
|
|
46
|
+
assert isinstance(filename, str)
|
|
47
|
+
self.score = score
|
|
48
|
+
self.filepath = os.path.join(dir, filename)
|
|
49
|
+
|
|
50
|
+
class ModelSaver(object):
|
|
51
|
+
"""Save the best models to disk"""
|
|
52
|
+
def __init__(
|
|
53
|
+
self,
|
|
54
|
+
dir: str = "checkpoints",
|
|
55
|
+
keep_best: int = 5,
|
|
56
|
+
keep_latest: int = 1,
|
|
57
|
+
save_optimizer: bool = False,
|
|
58
|
+
compare_fn: Callable[[float, float], bool] = lambda x,y: x.score < y.score,
|
|
59
|
+
sort_reverse: bool = False,
|
|
60
|
+
log_fn: Callable[[str], None] = logging.info
|
|
61
|
+
):
|
|
62
|
+
"""Init the ModelSaver
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
dir: The directory where models should be saved
|
|
66
|
+
keep_best: The number of best scoring models to keep
|
|
67
|
+
keep_latest: The number of latest models to keep
|
|
68
|
+
save_optimizer: Also save optimizer state?
|
|
69
|
+
compare_fn: Function that compares two scores
|
|
70
|
+
sort_reverse: Reverse sort order?
|
|
71
|
+
log_fn: Function to write logs
|
|
72
|
+
"""
|
|
73
|
+
assert isinstance(dir, str)
|
|
74
|
+
assert isinstance(keep_best, int)
|
|
75
|
+
assert isinstance(keep_latest, int)
|
|
76
|
+
assert isinstance(save_optimizer, bool)
|
|
77
|
+
assert callable(compare_fn)
|
|
78
|
+
assert isinstance(sort_reverse, bool)
|
|
79
|
+
assert callable(log_fn)
|
|
80
|
+
self.best_candidates = []
|
|
81
|
+
self.latest_candidates = []
|
|
82
|
+
# The destination directory (make if necessary)
|
|
83
|
+
self.dir = dir
|
|
84
|
+
if not os.path.exists(self.dir):
|
|
85
|
+
os.makedirs(self.dir)
|
|
86
|
+
self.keep_best = keep_best
|
|
87
|
+
self.keep_latest = keep_latest
|
|
88
|
+
self.save_optimizer = save_optimizer
|
|
89
|
+
self.compare_fn_best = compare_fn
|
|
90
|
+
self.compare_fn_latest = lambda x,y: x.score > y.score
|
|
91
|
+
self.sort_reverse = sort_reverse
|
|
92
|
+
self.log_fn = log_fn
|
|
93
|
+
|
|
94
|
+
def __save(self, info, filepath: str):
|
|
95
|
+
"""Save a model to disk.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
info: Tuple with torch model, optimizer, epoch, scaler, and args
|
|
99
|
+
filepath: The filepath to save to
|
|
100
|
+
"""
|
|
101
|
+
assert isinstance(filepath, str)
|
|
102
|
+
# Unpack info
|
|
103
|
+
model, optimizer, epoch, scaler, args = info
|
|
104
|
+
# Save model
|
|
105
|
+
if self.save_optimizer:
|
|
106
|
+
# Save full information to support resume training
|
|
107
|
+
to_save = {
|
|
108
|
+
"model": model.state_dict(),
|
|
109
|
+
"optimizer": optimizer.state_dict(),
|
|
110
|
+
"epoch": epoch,
|
|
111
|
+
"args": args
|
|
112
|
+
}
|
|
113
|
+
if scaler is not None:
|
|
114
|
+
to_save['scaler'] = scaler.state_dict()
|
|
115
|
+
else:
|
|
116
|
+
# Save only state dict
|
|
117
|
+
to_save = {"model": model.state_dict(), "args": args}
|
|
118
|
+
torch.save(to_save, filepath + ".pt")
|
|
119
|
+
|
|
120
|
+
def get_best_score(self) -> Union[float, None]:
|
|
121
|
+
"""Get the currently best score.
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
score: Best score or None if no models saved
|
|
125
|
+
"""
|
|
126
|
+
if len(self.best_candidates) == 0:
|
|
127
|
+
return None
|
|
128
|
+
else:
|
|
129
|
+
return self.best_candidates[0].score
|
|
130
|
+
|
|
131
|
+
def save_keep(self, info, step: int, name: str):
|
|
132
|
+
"""Save and keep the given model.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
info: Tuple with torch model, optimizer, epoch, scaler, and args
|
|
136
|
+
step: The current training step
|
|
137
|
+
name: The model name
|
|
138
|
+
"""
|
|
139
|
+
assert isinstance(step, int)
|
|
140
|
+
assert isinstance(name, str)
|
|
141
|
+
self.log_fn("Saving and keeping model for step {}".format(step))
|
|
142
|
+
filepath = os.path.join(self.dir, name + "_keep_" + str(step))
|
|
143
|
+
self.__save(info=info, filepath=filepath)
|
|
144
|
+
|
|
145
|
+
def save_latest(self, info, step: int, name: str):
|
|
146
|
+
"""Save the given model as currently latest.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
info: Tuple with torch model, optimizer, epoch, scaler, and args
|
|
150
|
+
step: The current training step
|
|
151
|
+
name: The model name
|
|
152
|
+
"""
|
|
153
|
+
assert isinstance(step, int)
|
|
154
|
+
assert isinstance(name, str)
|
|
155
|
+
name = name + "_latest_" + str(step)
|
|
156
|
+
# Use step as score
|
|
157
|
+
candidate = Candidate(score=step, dir=self.dir, filename=name)
|
|
158
|
+
if len(self.latest_candidates) < self.keep_latest \
|
|
159
|
+
or self.compare_fn_latest(candidate, self.latest_candidates[-1]):
|
|
160
|
+
self.log_fn("Saving latest model for step {}".format(step))
|
|
161
|
+
# Keep candidate
|
|
162
|
+
self.latest_candidates.append(candidate)
|
|
163
|
+
self.latest_candidates = sorted(
|
|
164
|
+
self.latest_candidates, key=lambda x: x.score, reverse=True)
|
|
165
|
+
# Save candidate
|
|
166
|
+
self.__save(info, filepath=candidate.filepath)
|
|
167
|
+
# Prune candidate
|
|
168
|
+
for candidate in self.latest_candidates[self.keep_latest:]:
|
|
169
|
+
for file in glob.glob(r'{}*'.format(candidate.filepath)):
|
|
170
|
+
os.remove(file)
|
|
171
|
+
self.latest_candidates = self.latest_candidates[0:self.keep_latest]
|
|
172
|
+
|
|
173
|
+
def save_best(self, info, score: float, step: int, name: str):
|
|
174
|
+
"""Save the given model as a candidate for best model.
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
model: The model to be saved as candidate for best model
|
|
178
|
+
score: The score achieved by the model
|
|
179
|
+
step: The current training step
|
|
180
|
+
name: The name of the model
|
|
181
|
+
"""
|
|
182
|
+
assert isinstance(score, float)
|
|
183
|
+
assert isinstance(step, int)
|
|
184
|
+
assert isinstance(name, str)
|
|
185
|
+
self.log_fn('Saving model for step {}'.format(step))
|
|
186
|
+
name = name + "_best_" + str(step)
|
|
187
|
+
candidate = Candidate(score, dir=self.dir, filename=name)
|
|
188
|
+
if len(self.best_candidates) < self.keep_best \
|
|
189
|
+
or self.compare_fn_best(candidate, self.best_candidates[-1]):
|
|
190
|
+
# Keep candidate
|
|
191
|
+
self.log_fn("Keeping model {} with score {:.4f}".format(
|
|
192
|
+
candidate.filepath, candidate.score))
|
|
193
|
+
self.best_candidates.append(candidate)
|
|
194
|
+
self.best_candidates = sorted(
|
|
195
|
+
self.best_candidates, key=lambda x: x.score, reverse=self.sort_reverse)
|
|
196
|
+
# Save candidate
|
|
197
|
+
self.__save(info, filepath=candidate.filepath)
|
|
198
|
+
# Prune candidates
|
|
199
|
+
for candidate in self.best_candidates[self.keep_best:]:
|
|
200
|
+
self.log_fn('Removing old model {} with score {:.4f}'.format(
|
|
201
|
+
candidate.filepath, candidate.score))
|
|
202
|
+
for file in glob.glob(r'{}*'.format(candidate.filepath)):
|
|
203
|
+
os.remove(file)
|
|
204
|
+
self.best_candidates = self.best_candidates[0:self.keep_best]
|
|
205
|
+
else:
|
|
206
|
+
# Skip the candidate
|
|
207
|
+
self.log_fn('Skipping candidate {}'.format(candidate.filepath))
|
|
208
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2024 Philipp Rouast
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: prpy
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Collection of Python utils for signal, image, and video processing
|
|
5
|
+
Author-email: Philipp Rouast <philipp@rouast.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
Project-URL: Repository, https://github.com/prouast/prpy.git
|
|
8
|
+
Project-URL: Issues, https://github.com/prouast/prpy/issues
|
|
9
|
+
Keywords: python,numpy,ffmpeg,tensorflow,torch
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Provides-Extra: ffmpeg
|
|
18
|
+
Requires-Dist: ffmpeg-python ; extra == 'ffmpeg'
|
|
19
|
+
Requires-Dist: numpy ; extra == 'ffmpeg'
|
|
20
|
+
Provides-Extra: numpy
|
|
21
|
+
Requires-Dist: numpy ; extra == 'numpy'
|
|
22
|
+
Requires-Dist: scipy ; extra == 'numpy'
|
|
23
|
+
Requires-Dist: Pillow ; extra == 'numpy'
|
|
24
|
+
Requires-Dist: opencv-python ; extra == 'numpy'
|
|
25
|
+
Requires-Dist: scikit-learn ; extra == 'numpy'
|
|
26
|
+
Provides-Extra: numpy_min
|
|
27
|
+
Requires-Dist: numpy ; extra == 'numpy_min'
|
|
28
|
+
Requires-Dist: scipy ; extra == 'numpy_min'
|
|
29
|
+
Requires-Dist: Pillow ; extra == 'numpy_min'
|
|
30
|
+
Provides-Extra: tensorflow
|
|
31
|
+
Requires-Dist: tensorflow ==2.12.1 ; extra == 'tensorflow'
|
|
32
|
+
Requires-Dist: numpy ; extra == 'tensorflow'
|
|
33
|
+
Provides-Extra: test
|
|
34
|
+
Requires-Dist: pytest ; extra == 'test'
|
|
35
|
+
Requires-Dist: flake8 ; extra == 'test'
|
|
36
|
+
Provides-Extra: torch
|
|
37
|
+
Requires-Dist: torch ==2.1.0 ; extra == 'torch'
|
|
38
|
+
|
|
39
|
+
[](https://github.com/prouast/prpy/actions/workflows/main.yml)
|
|
40
|
+
|
|
41
|
+
# prpy
|
|
42
|
+
|
|
43
|
+
A collection of Python utilities for signal, image, and video processing.
|
|
44
|
+
It contains subpackages for working with `numpy`, `ffmpeg`, `tensorflow`, and `torch`.
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
General prerequisites are `python>=3.8` and `ffmpeg` installed and accessible via the `$PATH` environment variable.
|
|
49
|
+
|
|
50
|
+
To install `prpy` and its dependencies:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
git clone https://github.com/prouast/prpy.git
|
|
54
|
+
pip install "./prpy[ffmpeg,numpy,tensorflow,torch,test]"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The above runs a full install of all dependencies.
|
|
58
|
+
It is possible to customize the install of the dependencies by only listing the desired subpackages out of `ffmpeg`, `numpy`, `tensorflow`, `torch`, and `test` in the square brackets above.
|
|
59
|
+
|
|
60
|
+
## Linting and tests
|
|
61
|
+
|
|
62
|
+
To lint and run tests:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
66
|
+
pytest
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Build
|
|
70
|
+
|
|
71
|
+
To build:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
python -m build
|
|
75
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
prpy/__init__.py,sha256=k16PtlPaiqybAKA7he03xqNVCa1v6yhIpRpjJvnTLzg,1093
|
|
2
|
+
prpy/constants.py,sha256=bApkiDwFer5shNg14nEsA5g5qhRA3oFQ5Ptx2IeAWfY,1209
|
|
3
|
+
prpy/ffmpeg/__init__.py,sha256=k16PtlPaiqybAKA7he03xqNVCa1v6yhIpRpjJvnTLzg,1093
|
|
4
|
+
prpy/ffmpeg/probe.py,sha256=Qfxl2t4-DoaX7i3cQemiwHEwIL-DPKV4wNHnvR30gWE,3126
|
|
5
|
+
prpy/ffmpeg/readwrite.py,sha256=wX3E4yaPCBDmUZGUVppDevEVf7GyPqhQw0tE33mId7g,16971
|
|
6
|
+
prpy/ffmpeg/utils.py,sha256=1wBnHw9njbXMXZiQCwJx60_zKy7Kj4wAtvyvVsi6DYI,3195
|
|
7
|
+
prpy/numpy/__init__.py,sha256=k16PtlPaiqybAKA7he03xqNVCa1v6yhIpRpjJvnTLzg,1093
|
|
8
|
+
prpy/numpy/face.py,sha256=lCK35xHoEow-_cgMtotj7kxsD_mWNOqtSOmWpgmEddI,8314
|
|
9
|
+
prpy/numpy/image.py,sha256=Sxwe8-rAmuFCxRUki5P0sQUlgcKuXdKNZvDN4nmfRXY,7064
|
|
10
|
+
prpy/numpy/metric.py,sha256=nXIQaNET2-yQOslIPcMKGi3w2_XIeHkiyO1M78gS5tQ,6395
|
|
11
|
+
prpy/numpy/signal.py,sha256=hkxr0paVkKvLOrqny_2Kh_pbKK4GrVBRn_EjO0ogyxU,21767
|
|
12
|
+
prpy/numpy/stride_tricks.py,sha256=sDpEyIfx6R81kjtVaWL-lXVa8gQu8_-s0Ky8-QJzJ-M,7764
|
|
13
|
+
prpy/tensorflow/__init__.py,sha256=k16PtlPaiqybAKA7he03xqNVCa1v6yhIpRpjJvnTLzg,1093
|
|
14
|
+
prpy/tensorflow/image.py,sha256=2EM2G76C2qXj5b3ZgeA5_5oe7yO6NJJRuCyrYYFCXZ0,7554
|
|
15
|
+
prpy/tensorflow/loss.py,sha256=IUI7P38IJHdvsdxd2NAOADhpN6xVNEloOZBWIDcuViA,4248
|
|
16
|
+
prpy/tensorflow/lr_schedule.py,sha256=18VLjCmMICngNH0NsPC7zUekwA1X1v5WN7y_pVFvrFE,3384
|
|
17
|
+
prpy/tensorflow/model_saver.py,sha256=sErMFd88gfxRcuSDoO7zWjIEvW4ZNW4MmvvjFZmWJSM,7660
|
|
18
|
+
prpy/tensorflow/nan.py,sha256=4DnZxkQC7_lOdhyndyxtDqsKeyHvcDJ3n6f02gdQQzQ,8525
|
|
19
|
+
prpy/tensorflow/optimizer.py,sha256=sFglHF4fCdvpjt0fAgGzye7MpqM343S4xjboRUF1zR4,9844
|
|
20
|
+
prpy/tensorflow/signal.py,sha256=2F2OPNTvtf3Z5V94pk4RDLS_t0YwvhXHjYGBBcRd6a8,3326
|
|
21
|
+
prpy/torch/__init__.py,sha256=k16PtlPaiqybAKA7he03xqNVCa1v6yhIpRpjJvnTLzg,1093
|
|
22
|
+
prpy/torch/model_saver.py,sha256=ScN73UfVpwl7M_5uSPg8gfY2DTODxgkVR8-iuvqVZlE,7582
|
|
23
|
+
prpy-0.2.2.dist-info/LICENSE,sha256=y4jYVUDrsgKYhTzvNU5lVhyZa7MEWRPg1caumfBviTc,1058
|
|
24
|
+
prpy-0.2.2.dist-info/METADATA,sha256=oX4lSZK7as0wAYExBlvhHH2wR8B41ZojQsf-ICa3v-A,2465
|
|
25
|
+
prpy-0.2.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
26
|
+
prpy-0.2.2.dist-info/top_level.txt,sha256=tWXjV62yfTm26Dhnt6xUpyHXt1GfB2TObPnQz8WJeg0,5
|
|
27
|
+
prpy-0.2.2.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
prpy
|