From 480fea7b6b894a40b6e0c2f783d21b7d0f3b00d6 Mon Sep 17 00:00:00 2001 From: HypoX64 Date: Sun, 30 Aug 2020 20:57:33 +0800 Subject: [PATCH] Fix training part #5 --- cores/options.py | 11 ++++++----- deepmosaic.py | 2 +- make_datasets/make_pix2pix_dataset.py | 8 +++++++- train/add/train.py | 2 ++ train/clean/train.py | 2 ++ util/image_processing.py | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/cores/options.py b/cores/options.py index 9d6ff95..69a6853 100644 --- a/cores/options.py +++ b/cores/options.py @@ -50,7 +50,7 @@ class Options(): self.initialized = True - def getparse(self): + def getparse(self, test_flag = False): if not self.initialized: self.initialize() self.opt = self.parser.parse_args() @@ -65,10 +65,11 @@ class Options(): else: self.opt.use_gpu = -1 - if not os.path.exists(self.opt.media_path): - print('Error: Bad media path!') - input('Please press any key to exit.\n') - exit(0) + if test_flag: + if not os.path.exists(self.opt.media_path): + print('Error: Bad media path!') + input('Please press any key to exit.\n') + exit(0) if self.opt.mode == 'auto': if 'clean' in model_name or self.opt.traditional: diff --git a/deepmosaic.py b/deepmosaic.py index cb93bfa..ee71f4a 100644 --- a/deepmosaic.py +++ b/deepmosaic.py @@ -5,7 +5,7 @@ from cores import Options,core from util import util from models import loadmodel -opt = Options().getparse() +opt = Options().getparse(test_flag = True) util.file_init(opt) def main(): diff --git a/make_datasets/make_pix2pix_dataset.py b/make_datasets/make_pix2pix_dataset.py index 58949c8..c9ccb87 100644 --- a/make_datasets/make_pix2pix_dataset.py +++ b/make_datasets/make_pix2pix_dataset.py @@ -106,7 +106,13 @@ for fold in range(opt.fold): # t.start() saveflag = True - x,y,size,area = impro.boundingSquare(mask, random.uniform(1.4,1.6)) + if opt.mod == ['drawn','irregular']: + x,y,size,area = impro.boundingSquare(mask_drawn, random.uniform(1.2,1.6)) + elif opt.mod == ['network','irregular']: + x,y,size,area = impro.boundingSquare(mask_net, random.uniform(1.2,1.6)) + else: + x,y,size,area = impro.boundingSquare(mask, random.uniform(1.2,1.6)) + if area < 1000: saveflag = False else: diff --git a/train/add/train.py b/train/add/train.py index 385b149..d64063e 100644 --- a/train/add/train.py +++ b/train/add/train.py @@ -10,6 +10,8 @@ import datetime import time import numpy as np +import matplotlib +matplotlib.use('Agg') from matplotlib import pyplot as plt import cv2 diff --git a/train/clean/train.py b/train/clean/train.py index 7c179e7..70efb41 100644 --- a/train/clean/train.py +++ b/train/clean/train.py @@ -16,6 +16,8 @@ from multiprocessing import Process, Queue from util import mosaic,util,ffmpeg,filt,data from util import image_processing as impro from models import pix2pix_model,pix2pixHD_model,video_model,unet_model,loadmodel,videoHD_model +import matplotlib +matplotlib.use('Agg') from matplotlib import pyplot as plt import torch.backends.cudnn as cudnn diff --git a/util/image_processing.py b/util/image_processing.py index d19d643..662ef07 100755 --- a/util/image_processing.py +++ b/util/image_processing.py @@ -79,7 +79,7 @@ def ch_one2three(img): res = cv2.merge([img, img, img]) return res -def color_adjust(img,alpha=1,beta=0,b=0,g=0,r=0,ran = False): +def color_adjust(img,alpha=0,beta=0,b=0,g=0,r=0,ran = False): ''' g(x) = (1+α)g(x)+255*β, g(x) = g(x[:+b*255,:+g*255,:+r*255]) -- GitLab