-
Notifications
You must be signed in to change notification settings - Fork 4
/
save_gif.py
36 lines (28 loc) · 1.01 KB
/
save_gif.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import cv2
from imageio import mimsave
from tqdm import tqdm
from qudida import DomainAdapter
from test_transforms import params_combinations
def _get_colorspace_name(x):
d = {None: 'RGB',
cv2.COLOR_YCrCb2BGR: 'YCrCb',
cv2.COLOR_HSV2BGR: 'HSV',
}
return d[x]
def save_gif():
frames = []
for t, c in tqdm(params_combinations()):
adapter = DomainAdapter(transformer=t,
ref_img=cv2.imread('target.png'),
color_conversions=c,
)
source = cv2.imread('source.png')
result = adapter(source)
result = cv2.putText(result,
f'{t.__class__.__name__}, colorspace {_get_colorspace_name(c[1])}',
(20, 30),
fontScale=1, fontFace=cv2.FONT_HERSHEY_SIMPLEX, color=(0, 0, 0))
frames.append(result)
mimsave('result.gif', frames, fps=1)
if __name__ == '__main__':
save_gif()