ソースを参照

Change the jpeg config for the photo model

nagadomi 9 年 前
コミット
b5db84d42e
2 ファイル変更14 行追加5 行削除
  1. 10 4
      lib/pairwise_transform.lua
  2. 4 1
      train_ukbench.sh

+ 10 - 4
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

+ 4 - 1
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