Bladeren bron

Remove cleanup_model.lua; Change model format from binary to ascii

nagadomi 9 jaren geleden
bovenliggende
commit
664322fa97
4 gewijzigde bestanden met toevoegingen van 3 en 36 verwijderingen
  1. 0 25
      tools/cleanup_model.lua
  2. 2 2
      train.lua
  3. 0 5
      train.sh
  4. 1 4
      train_photo.sh

+ 0 - 25
tools/cleanup_model.lua

@@ -1,25 +0,0 @@
-require 'pl'
-local __FILE__ = (function() return string.gsub(debug.getinfo(2, 'S').source, "^@", "") end)()
-package.path = path.join(path.dirname(__FILE__), "..", "lib", "?.lua;") .. package.path
-
-require 'w2nn'
-torch.setdefaulttensortype("torch.FloatTensor")
-
-local cmd = torch.CmdLine()
-cmd:text()
-cmd:text("cleanup model")
-cmd:text("Options:")
-cmd:option("-model", "./model.t7", 'path of model file')
-cmd:option("-iformat", "binary", 'input format')
-cmd:option("-oformat", "binary", 'output format')
-
-local opt = cmd:parse(arg)
-local model = torch.load(opt.model, opt.iformat)
-if model then
-   w2nn.cleanup_model(model)
-   model:cuda()
-   model:evaluate()
-   torch.save(opt.model, model, opt.oformat)
-else
-   error("model not found")
-end

+ 2 - 2
train.lua

@@ -210,7 +210,7 @@ local function train()
 	    best_score = score
 	    print("* update best model")
 	    if settings.save_history then
-	       torch.save(string.format(settings.model_file, epoch, i), model:clearState())
+	       torch.save(string.format(settings.model_file, epoch, i), model:clearState(), "ascii")
 	       if settings.method == "noise" then
 		  local log = path.join(settings.model_dir,
 					("noise%d_best.%d-%d.png"):format(settings.noise_level,
@@ -223,7 +223,7 @@ local function train()
 		  save_test_scale(model, test_image, log)
 	       end
 	    else
-	       torch.save(settings.model_file, model:clearState())
+	       torch.save(settings.model_file, model:clearState(), "ascii")
 	       if settings.method == "noise" then
 		  local log = path.join(settings.model_dir,
 					("noise%d_best.png"):format(settings.noise_level))

+ 0 - 5
train.sh

@@ -3,10 +3,5 @@
 th convert_data.lua
 
 th train.lua -method scale -model_dir models/anime_style_art_rgb -test images/miku_small.png -thread 4
-th tools/cleanup_model.lua -model models/anime_style_art_rgb/scale2.0x_model.t7 -oformat ascii
-
 th train.lua -method noise -noise_level 1 -style art -model_dir models/anime_style_art_rgb -test images/miku_noisy.png -thread 4
-th tools/cleanup_model.lua -model models/anime_style_art_rgb/noise1_model.t7 -oformat ascii
-
 th train.lua -method noise -noise_level 2 -style art -model_dir models/anime_style_art_rgb -test images/miku_noisy.png -thread 4
-th tools/cleanup_model.lua -model models/anime_style_art_rgb/noise2_model.t7 -oformat ascii

+ 1 - 4
train_photo.sh

@@ -2,11 +2,8 @@
 
 th convert_data.lua -style photo -data_dir ./data/photo -model_dir models/photo
 
-th train.lua -style photo -method scale -data_dir ./data/photo -model_dir models/photo_uk -test work/scale_test_photo.png -color rgb -thread 4 -backend cudnn -random_unsharp_mask_rate 0.1 -validation_crops 160
-th tools/cleanup_model.lua -model models/photo/scale2.0x_model.t7 -oformat ascii
+th train.lua -style photo -method scale -data_dir ./data/photo -model_dir models/photo -test work/scale_test_photo.png -color rgb -thread 4 -backend cudnn -random_unsharp_mask_rate 0.1 -validation_crops 160
 
 th train.lua -style photo -method noise -noise_level 1 -data_dir ./data/photo -model_dir models/photo -test work/noise_test_photo.jpg -color rgb -thread 4 -backend cudnn -random_unsharp_mask_rate 0.5 -validation_crops 160 -nr_rate 0.6 -epoch 33
-th tools/cleanup_model.lua -model models/photo/noise1_model.t7 -oformat ascii
 
 th train.lua -style photo -method noise -noise_level 2 -data_dir ./data/photo -model_dir models/photo -test work/noise_test_photo.jpg -color rgb -thread 4 -backend cudnn -random_unsharp_mask_rate 0.5 -validation_crops 160 -nr_rate 0.8 -epoch 38
-th tools/cleanup_model.lua -model models/photo/noise2_model.t7 -oformat ascii