diff --git a/README.md b/README.md index f45c07f6abcc9c3f79d6a995469206f81d2c8490..7197a0f5ce0c02ac0fa0c4dadc84332191471be6 100755 --- a/README.md +++ b/README.md @@ -67,11 +67,11 @@ You can download pre_trained models and put them into './pretrained_models'.
#### Simple example * Add Mosaic (output media will save in './result')
```bash -python3 deepmosaic.py --media_path ./imgs/ruoruo.jpg --model_path ./pretrained_models/mosaic/add_face.pth --use_gpu 0 +python deepmosaic.py --media_path ./imgs/ruoruo.jpg --model_path ./pretrained_models/mosaic/add_face.pth --use_gpu 0 ``` * Clean Mosaic (output media will save in './result')
```bash -python3 deepmosaic.py --media_path ./result/ruoruo_add.jpg --model_path ./pretrained_models/mosaic/clean_face_HD.pth --use_gpu 0 +python deepmosaic.py --media_path ./result/ruoruo_add.jpg --model_path ./pretrained_models/mosaic/clean_face_HD.pth --use_gpu 0 ``` #### More parameters If you want to test other image or video, please refer to this file.
diff --git a/README_CN.md b/README_CN.md index c7c84d525c3a8ecb9a08f0a7e59b0454f3692d4a..de371617b1fa7a93e62b8a6483599353c11f5ba0 100644 --- a/README_CN.md +++ b/README_CN.md @@ -64,11 +64,11 @@ cd DeepMosaics #### 简单的例子 * 为视频添加马赛克,例子中认为脸是需要打码的区域 ,可以通过切换预训练模型切换自动打码区域(输出结果将储存到 './result')
```bash -python3 deepmosaic.py --media_path ./imgs/ruoruo.jpg --model_path ./pretrained_models/mosaic/add_face.pth --use_gpu 0 +python deepmosaic.py --media_path ./imgs/ruoruo.jpg --model_path ./pretrained_models/mosaic/add_face.pth --use_gpu 0 ``` * 将视频中的马赛克移除,对于不同的打码物体需要使用对应的预训练模型进行马赛克消除(输出结果将储存到 './result')
```bash -python3 deepmosaic.py --media_path ./result/ruoruo_add.jpg --model_path ./pretrained_models/mosaic/clean_face_HD.pth --use_gpu 0 +python deepmosaic.py --media_path ./result/ruoruo_add.jpg --model_path ./pretrained_models/mosaic/clean_face_HD.pth --use_gpu 0 ``` #### 更多的参数 如果想要测试其他的图片或视频,请参照以下文件输入参数.
diff --git a/cores/options.py b/cores/options.py index 69a68534cb6ecf99f4bca6f06daaff0f4a57afc9..83748ebe68fd02de5b9ad8a4dec2ed8fc93efe6d 100644 --- a/cores/options.py +++ b/cores/options.py @@ -13,7 +13,7 @@ class Options(): self.parser.add_argument('--use_gpu', type=int,default=0, help='if -1, use cpu') self.parser.add_argument('--media_path', type=str, default='./imgs/ruoruo.jpg',help='your videos or images path') self.parser.add_argument('-ss', '--start_time', type=str, default='00:00:00',help='start position of video, default is the beginning of video') - self.parser.add_argument('-t', '--last_time', type=str, default='00:00:00',help='limit the duration of the video, default is the entire video') + self.parser.add_argument('-t', '--last_time', type=str, default='00:00:00',help='duration of the video, default is the entire video') self.parser.add_argument('--mode', type=str, default='auto',help='Program running mode. auto | add | clean | style') self.parser.add_argument('--model_path', type=str, default='./pretrained_models/mosaic/add_face.pth',help='pretrained model path') self.parser.add_argument('--result_dir', type=str, default='./result',help='output media will be saved here') diff --git a/deepmosaic.py b/deepmosaic.py index ee71f4ab28d6b1f21daf1278e2ea967fc5776070..132673f2aa763dee6a35e7bd2ede986dc4324c97 100644 --- a/deepmosaic.py +++ b/deepmosaic.py @@ -65,6 +65,17 @@ if __name__ == '__main__': print('Finished!') except Exception as ex: print('--------------------ERROR--------------------') + print('--------------Environment--------------') + print('DeepMosaics: 0.4.0') + print('Python:',sys.version) + import torch + print('Pytorch:',torch.__version__) + import cv2 + print('OpenCV:',cv2.__version__) + import platform + print('Platform:',platform.platform()) + + print('--------------BUG--------------') ex_type, ex_val, ex_stack = sys.exc_info() print('Error Type:',ex_type) print(ex_val) diff --git a/util/image_processing.py b/util/image_processing.py index 662ef073f2ef57c4ebb28c6ec7ee7af3b28c666b..722a00005d4b052f975b0718ce1fcaa152ce676a 100755 --- a/util/image_processing.py +++ b/util/image_processing.py @@ -24,7 +24,7 @@ def imread(file_path,mod = 'normal',loadsize = 0): ''' if system_type == 'Linux': if mod == 'normal': - img = cv2.imread(file_path) + img = cv2.imread(file_path,1) elif mod == 'gray': img = cv2.imread(file_path,0) elif mod == 'all': @@ -33,11 +33,13 @@ def imread(file_path,mod = 'normal',loadsize = 0): #In windows, for chinese path, use cv2.imdecode insteaded. #It will loss EXIF, I can't fix it else: - if mod == 'gray': + if mod == 'normal': + img = cv2.imdecode(np.fromfile(file_path,dtype=np.uint8),1) + elif mod == 'gray': img = cv2.imdecode(np.fromfile(file_path,dtype=np.uint8),0) - else: + elif mod == 'all': img = cv2.imdecode(np.fromfile(file_path,dtype=np.uint8),-1) - + if loadsize != 0: img = resize(img, loadsize, interpolation=cv2.INTER_CUBIC)