-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
260 lines (211 loc) · 10.9 KB
/
test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
"""
Copyright 2025 by Herbert Potechius,
Technical University of Berlin
Faculty IV - Electrical Engineering and Computer Science - Institute of Telecommunication Systems - Communication Systems Group
All rights reserved.
This file is released under the "MIT License Agreement".
Please see the LICENSE file that should have been included as part of this package.
"""
from ColorTransferLib.DataTypes.Mesh import Mesh
from ColorTransferLib.DataTypes.VolumetricVideo import VolumetricVideo
from ColorTransferLib.DataTypes.Image import Image
from ColorTransferLib.DataTypes.Video import Video
from ColorTransferLib.ColorTransfer import ColorTransfer, ColorTransferEvaluation
from ColorTransferLib.DataTypes.LightField import LightField
from ColorTransferLib.DataTypes.GaussianSplatting import GaussianSplatting
import os
# List of abbreviations for all style transfer methods
st_methods = ["NST", "DPT", "PSN", "CAM", "ST2"]
# List of abbreviations for colorization methods
cz_methods = ["IIC", "CFM", "DDC"]
# List of abbreviations for all evaluation methods
ev_methods = ["PSNR", "HI", "Corr", "BA", "MSE", "RMSE", "CF", "MSSSIM", "SSIM", "GSSIM", "IVSSIM", "IVEGSSIM", "FSIM", "BRISQUE", "NIQE", "VSI", "CTQM", "LPIPS", "NIMA", "CSS"]
# ------------------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------
# METHOD TESTS
# (1) test_all_CT_methods: Test all color transfer methods for a single supported data type, typically image-to-image transfer.
# ------------------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------------------------------------------
def test_all_CT_all_datatypes(out_path):
# List of abbreviations for all color transfer methods
ct_methods = ["GLO", "BCC", "PDF", "CCS", "MKL", "GPC", "FUZ", "TPS", "HIS", "RHG", "EB3"]
ct_methods = ["GLO"]
print("Loading all files...")
# Source input
src_gs = GaussianSplatting(file_path='testdata/gaussiansplatting/plush.splat')
src_lf = LightField(file_path='testdata/lightfields/legolow_reduced.mp4', size=(3, 3))
src_vv = VolumetricVideo(folder_path='testdata/volumetricvideos/$volumetric$human', file_name='human')
src_im = Image(file_path='testdata/images/Mona_Lisa.png')
src_vd = Video(file_path='testdata/videos/test_vid_00.mp4')
src_pc = Mesh(file_path='testdata/pointclouds/Statue_Athena.ply', datatype="PointCloud")
src_me = Mesh(file_path='testdata/meshes/$mesh$Amethyst/Amethyst.obj', datatype="Mesh")
# Reference input
ref_gs = GaussianSplatting(file_path='testdata/gaussiansplatting/plush.splat')
ref_lf = LightField(file_path='testdata/lightfields/legolow_reduced.mp4', size=(3, 3))
ref_vv = VolumetricVideo(folder_path='testdata/volumetricvideos/$volumetric$human', file_name='human')
ref_im = Image(file_path='testdata/images/The_Scream.png')
ref_vd = Video(file_path='testdata/videos/test_vid_00.mp4')
ref_pc = Mesh(file_path='testdata/pointclouds/Orange.ply', datatype="PointCloud")
ref_me = Mesh(file_path='testdata/meshes/$mesh$Apple/Apple.obj', datatype="Mesh")
src_dict = {
"Image": src_im,
"Video": src_vd,
"GaussianSplatting": src_gs,
"LightField": src_lf,
"VolumetricVideo": src_vv,
"PointCloud": src_pc,
"Mesh": src_me
}
ref_dict = {
"Image": ref_im,
"Video": ref_vd,
"GaussianSplatting": ref_gs,
"LightField": ref_lf,
"VolumetricVideo": ref_vv,
"PointCloud": ref_pc,
"Mesh": ref_me
}
type_src_array = ["Image", "Video", "GaussianSplatting", "LightField", "VolumetricVideo", "PointCloud", "Mesh"]
type_ref_array = ["Image", "GaussianSplatting", "PointCloud", "Mesh"]
for method in ct_methods:
print("--------------------------------------")
print("- Method: " + method)
print("--------------------------------------")
# Create output directory
if not os.path.exists(out_path + "/" + method):
os.makedirs(out_path + "/" + method)
for src_type in type_src_array:
for ref_type in type_ref_array:
print("Processing: " + method + " - " + src_type + " -> " + ref_type + " ...", end=' ')
src = src_dict[src_type]
ref = ref_dict[ref_type]
ct = ColorTransfer(src, ref, method)
out = ct.apply()
#print(out)
#exit()
if out["status_code"] == 0:
out["object"].write(f"{out_path}/{method}/"+ method + "_" + src_type + "_" + ref_type)
print("\033[92mDone\033[0m")
else:
print(f'\033[93m{out["response"]}\033[0m')
# ------------------------------------------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------------------------------------------
def test_all_ST_all_datatypes(out_path):
# List of abbreviations for all color transfer methods
ct_methods = ["NST", "DPT", "PSN", "CAM", "ST2"]
print("Loading all files...")
# Source input
src_gs = GaussianSplatting(file_path='testdata/gaussiansplatting/plush.splat')
src_lf = LightField(file_path='testdata/lightfields/legolow_reduced.mp4', size=(3, 3))
src_vv = VolumetricVideo(folder_path='testdata/volumetricvideos/$volumetric$human', file_name='human')
src_im = Image(file_path='testdata/images/Mona_Lisa.png')
src_vd = Video(file_path='testdata/videos/test_vid_00.mp4')
src_pc = Mesh(file_path='testdata/pointclouds/Statue_Athena.ply', datatype="PointCloud")
src_me = Mesh(file_path='testdata/meshes/$mesh$Amethyst/Amethyst.obj', datatype="Mesh")
# Reference input
ref_gs = GaussianSplatting(file_path='testdata/gaussiansplatting/plush.splat')
ref_lf = LightField(file_path='testdata/lightfields/legolow_reduced.mp4', size=(3, 3))
ref_vv = VolumetricVideo(folder_path='testdata/volumetricvideos/$volumetric$human', file_name='human')
ref_im = Image(file_path='testdata/images/The_Scream.png')
ref_vd = Video(file_path='testdata/videos/test_vid_00.mp4')
ref_pc = Mesh(file_path='testdata/pointclouds/Azurit.ply', datatype="PointCloud")
ref_me = Mesh(file_path='testdata/meshes/$mesh$Apple/Apple.obj', datatype="Mesh")
src_dict = {
"Image": src_im,
"Video": src_vd,
"GaussianSplatting": src_gs,
"LightField": src_lf,
"VolumetricVideo": src_vv,
"PointCloud": src_pc,
"Mesh": src_me
}
ref_dict = {
"Image": ref_im,
"Video": ref_vd,
"GaussianSplatting": ref_gs,
"LightField": ref_lf,
"VolumetricVideo": ref_vv,
"PointCloud": ref_pc,
"Mesh": ref_me
}
type_src_array = ["Image", "Video", "GaussianSplatting", "LightField", "VolumetricVideo", "PointCloud", "Mesh"]
type_ref_array = ["Image", "GaussianSplatting", "PointCloud", "Mesh"]
for method in ct_methods:
print("--------------------------------------")
print("- Method: " + method)
print("--------------------------------------")
# Create output directory
if not os.path.exists(out_path + "/" + method):
os.makedirs(out_path + "/" + method)
for src_type in type_src_array:
for ref_type in type_ref_array:
print("Processing: " + method + " - " + src_type + " -> " + ref_type + " ...", end=' ')
src = src_dict[src_type]
ref = ref_dict[ref_type]
ct = ColorTransfer(src, ref, method)
out = ct.apply()
#print(out)
#exit()
if out["status_code"] == 0:
out["object"].write(f"{out_path}/{method}/"+ method + "_" + src_type + "_" + ref_type)
print("\033[92mDone\033[0m")
else:
print(f'\033[93m{out["response"]}\033[0m')
# ------------------------------------------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------------------------------------------
def test_all_CZ_all_datatypes(out_path):
# List of abbreviations for all color transfer methods
ct_methods = ["IIC", "CFM", "DDC"]
print("Loading all files...")
# Source input
src_im = Image(file_path='testdata/images/Mona_Lisa.png')
# Reference input
ref_im = Image(file_path='testdata/images/The_Scream.png')
src_dict = {
"Image": src_im,
}
ref_dict = {
"Image": ref_im,
}
type_src_array = ["Image"]
type_ref_array = ["Image"]
for method in ct_methods:
print("--------------------------------------")
print("- Method: " + method)
print("--------------------------------------")
# Create output directory
if not os.path.exists(out_path + "/" + method):
os.makedirs(out_path + "/" + method)
for src_type in type_src_array:
for ref_type in type_ref_array:
print("Processing: " + method + " - " + src_type + " -> " + ref_type + " ...", end=' ')
src = src_dict[src_type]
ref = ref_dict[ref_type]
ct = ColorTransfer(src, ref, method)
out = ct.apply()
#print(out)
#exit()
if out["status_code"] == 0:
out["object"].write(f"{out_path}/{method}/"+ method + "_" + src_type + "_" + ref_type)
print("\033[92mDone\033[0m")
else:
print(f'\033[93m{out["response"]}\033[0m')
# ------------------------------------------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------------------------------------------
def test_all_EVAL():
# List of abbreviations for all evaluation methods
ev_methods = ["PSNR", "HI", "Corr", "BA", "MSE", "RMSE", "CF", "MSSSIM", "SSIM", "GSSIM", "IVSSIM", "IVEGSSIM", "FSIM", "BRISQUE", "NIQE", "VSI", "CTQM", "LPIPS", "NIMA", "CSS"]
for method in ev_methods:
print("Processing: " + method + " ...", end=' ')
src = Image(file_path='testdata/eval_test/Mona_Lisa.png')
ref = Image(file_path='testdata/eval_test/The_Scream.png')
out = Image(file_path='testdata/eval_test/GLO_Image_Image.png')
cte = ColorTransferEvaluation(src, ref, out)
eva = cte.apply(method)
print(eva)