show baseline
This commit is contained in:
parent
f7b298690d
commit
c47df93505
1 changed files with 41 additions and 10 deletions
|
@ -69,12 +69,14 @@ end
|
||||||
local function benchmark(opt, x, input_func, model1, model2)
|
local function benchmark(opt, x, input_func, model1, model2)
|
||||||
local model1_mse = 0
|
local model1_mse = 0
|
||||||
local model2_mse = 0
|
local model2_mse = 0
|
||||||
|
local baseline_mse = 0
|
||||||
local model1_psnr = 0
|
local model1_psnr = 0
|
||||||
local model2_psnr = 0
|
local model2_psnr = 0
|
||||||
|
local baseline_psnr = 0
|
||||||
|
|
||||||
for i = 1, #x do
|
for i = 1, #x do
|
||||||
local ground_truth = x[i]
|
local ground_truth = x[i]
|
||||||
local input, model1_output, model2_output
|
local input, model1_output, model2_output, baseline_output
|
||||||
|
|
||||||
input = input_func(ground_truth, opt)
|
input = input_func(ground_truth, opt)
|
||||||
input = input:float():div(255)
|
input = input:float():div(255)
|
||||||
|
@ -91,6 +93,7 @@ local function benchmark(opt, x, input_func, model1, model2)
|
||||||
if model2 then
|
if model2 then
|
||||||
model2_output = reconstruct.scale(model2, 2.0, input)
|
model2_output = reconstruct.scale(model2, 2.0, input)
|
||||||
end
|
end
|
||||||
|
baseline_output = iproc.scale(input, input:size(3) * 2, input:size(2) * 2, opt.filter)
|
||||||
end
|
end
|
||||||
if opt.color == "y" then
|
if opt.color == "y" then
|
||||||
model1_mse = model1_mse + YMSE(ground_truth, model1_output)
|
model1_mse = model1_mse + YMSE(ground_truth, model1_output)
|
||||||
|
@ -99,6 +102,10 @@ local function benchmark(opt, x, input_func, model1, model2)
|
||||||
model2_mse = model2_mse + YMSE(ground_truth, model2_output)
|
model2_mse = model2_mse + YMSE(ground_truth, model2_output)
|
||||||
model2_psnr = model2_psnr + YPSNR(ground_truth, model2_output)
|
model2_psnr = model2_psnr + YPSNR(ground_truth, model2_output)
|
||||||
end
|
end
|
||||||
|
if baseline_output then
|
||||||
|
baseline_mse = baseline_mse + YMSE(ground_truth, baseline_output)
|
||||||
|
baseline_psnr = baseline_psnr + YPSNR(ground_truth, baseline_output)
|
||||||
|
end
|
||||||
elseif opt.color == "rgb" then
|
elseif opt.color == "rgb" then
|
||||||
model1_mse = model1_mse + MSE(ground_truth, model1_output)
|
model1_mse = model1_mse + MSE(ground_truth, model1_output)
|
||||||
model1_psnr = model1_psnr + PSNR(ground_truth, model1_output)
|
model1_psnr = model1_psnr + PSNR(ground_truth, model1_output)
|
||||||
|
@ -106,22 +113,46 @@ local function benchmark(opt, x, input_func, model1, model2)
|
||||||
model2_mse = model2_mse + MSE(ground_truth, model2_output)
|
model2_mse = model2_mse + MSE(ground_truth, model2_output)
|
||||||
model2_psnr = model2_psnr + PSNR(ground_truth, model2_output)
|
model2_psnr = model2_psnr + PSNR(ground_truth, model2_output)
|
||||||
end
|
end
|
||||||
|
if baseline_output then
|
||||||
|
baseline_mse = baseline_mse + MSE(ground_truth, baseline_output)
|
||||||
|
baseline_psnr = baseline_psnr + PSNR(ground_truth, baseline_output)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
error("Unknown color: " .. opt.color)
|
error("Unknown color: " .. opt.color)
|
||||||
end
|
end
|
||||||
if model2 then
|
if model2 then
|
||||||
io.stdout:write(
|
if baseline_output then
|
||||||
string.format("%d/%d; model1_mse=%f, model2_mse=%f, model1_psnr=%f, model2_psnr=%f \r",
|
io.stdout:write(
|
||||||
i, #x,
|
string.format("%d/%d; baseline_mse=%f, model1_mse=%f, model2_mse=%f, baseline_psnr=%f, model1_psnr=%f, model2_psnr=%f \r",
|
||||||
model1_mse / i, model2_mse / i,
|
i, #x,
|
||||||
model1_psnr / i, model2_psnr / i
|
baseline_mse / i,
|
||||||
|
model1_mse / i, model2_mse / i,
|
||||||
|
baseline_psnr / i,
|
||||||
|
model1_psnr / i, model2_psnr / i
|
||||||
))
|
))
|
||||||
|
else
|
||||||
|
io.stdout:write(
|
||||||
|
string.format("%d/%d; model1_mse=%f, model2_mse=%f, model1_psnr=%f, model2_psnr=%f \r",
|
||||||
|
i, #x,
|
||||||
|
model1_mse / i, model2_mse / i,
|
||||||
|
model1_psnr / i, model2_psnr / i
|
||||||
|
))
|
||||||
|
end
|
||||||
else
|
else
|
||||||
io.stdout:write(
|
if baseline_output then
|
||||||
string.format("%d/%d; model1_mse=%f, model1_psnr=%f \r",
|
io.stdout:write(
|
||||||
i, #x,
|
string.format("%d/%d; baseline_mse=%f, model1_mse=%f, baseline_psnr=%f, model1_psnr=%f \r",
|
||||||
model1_mse / i, model1_psnr / i
|
i, #x,
|
||||||
|
baseline_mse / i, model1_mse / i,
|
||||||
|
baseline_psnr / i, model1_psnr / i
|
||||||
))
|
))
|
||||||
|
else
|
||||||
|
io.stdout:write(
|
||||||
|
string.format("%d/%d; model1_mse=%f, model1_psnr=%f \r",
|
||||||
|
i, #x,
|
||||||
|
model1_mse / i, model1_psnr / i
|
||||||
|
))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
io.stdout:flush()
|
io.stdout:flush()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue