From b5db84d42e5fb5b07038e4725d087b8af4db9ca0 Mon Sep 17 00:00:00 2001 From: nagadomi Date: Sun, 15 Nov 2015 09:36:40 +0900 Subject: [PATCH] Change the jpeg config for the photo model --- lib/pairwise_transform.lua | 14 ++++++++++---- train_ukbench.sh | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/pairwise_transform.lua b/lib/pairwise_transform.lua index 9fd7fa4..a14d0a2 100644 --- a/lib/pairwise_transform.lua +++ b/lib/pairwise_transform.lua @@ -189,13 +189,19 @@ function pairwise_transform.jpeg(src, style, level, size, offset, n, options) end elseif style == "photo" then if level == 1 then - return pairwise_transform.jpeg_(src, {torch.random(80, 95)}, + return pairwise_transform.jpeg_(src, {torch.random(30, 75)}, size, offset, n, options) elseif level == 2 then - return pairwise_transform.jpeg_(src, {torch.random(65, 85)}, - size, offset, n, - options) + if torch.uniform() > 0.6 then + return pairwise_transform.jpeg_(src, {torch.random(30, 60)}, + size, offset, n, options) + else + local quality1 = torch.random(40, 60) + local quality2 = quality1 - torch.random(5, 10) + return pairwise_transform.jpeg_(src, {quality1, quality2}, + size, offset, n, options) + end else error("unknown noise level: " .. level) end diff --git a/train_ukbench.sh b/train_ukbench.sh index e72c526..6bdacf3 100755 --- a/train_ukbench.sh +++ b/train_ukbench.sh @@ -2,5 +2,8 @@ th convert_data.lua -data_dir ./data/ukbench -th train.lua -method scale -data_dir ./data/ukbench -model_dir models/ukbench -test images/lena.jpg -thread 4 +#th train.lua -style photo -method noise -noise_level 2 -data_dir ./data/ukbench -model_dir models/ukbench -test images/lena.png -nr_rate 0.9 -jpeg_sampling_factors 420 # -thread 4 -backend cudnn +#th tools/cleanup_model.lua -model models/ukbench/noise2_model.t7 -oformat ascii + +th train.lua -method scale -data_dir ./data/ukbench -model_dir models/ukbench -test images/lena.jpg # -thread 4 -backend cudnn th tools/cleanup_model.lua -model models/ukbench/scale2.0x_model.t7 -oformat ascii