提交 6ca84044 编写于 作者: H hypox64

Fix bug #28

上级 480fea7b
......@@ -67,11 +67,11 @@ You can download pre_trained models and put them into './pretrained_models'.<br>
#### Simple example
* Add Mosaic (output media will save in './result')<br>
```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')<br>
```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.<br>
......
......@@ -64,11 +64,11 @@ cd DeepMosaics
#### 简单的例子
* 为视频添加马赛克,例子中认为脸是需要打码的区域 ,可以通过切换预训练模型切换自动打码区域(输出结果将储存到 './result')<br>
```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')<br>
```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
```
#### 更多的参数
如果想要测试其他的图片或视频,请参照以下文件输入参数.<br>
......
......@@ -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')
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册