deepmosaic.py 1.0 KB
Newer Older
H
hypox64 已提交
1
import os
H
hypox64 已提交
2 3
from cores import Options,core
from util import util
H
hypox64 已提交
4 5

opt = Options().getparse()
H
hypox64 已提交
6
util.file_init(opt)
H
hypox64 已提交
7

H
hypox64 已提交
8
def main():
H
hypox64 已提交
9
    
H
hypox64 已提交
10
    if opt.mode == 'add':
H
hypox64 已提交
11 12 13 14 15 16
        if util.is_img(opt.media_path):
            core.addmosaic_img(opt)
        elif util.is_video(opt.media_path):
            core.addmosaic_video(opt)
        else:
            print('This type of file is not supported')
H
hypox64 已提交
17

H
hypox64 已提交
18
    elif opt.mode == 'clean':
H
hypox64 已提交
19 20 21 22 23 24 25 26 27
        if util.is_img(opt.media_path):
            core.cleanmosaic_img(opt)
        elif util.is_video(opt.media_path):
            if opt.netG == 'video':
                core.cleanmosaic_video_fusion(opt)
            else:
                core.cleanmosaic_video_byframe(opt)
        else:
            print('This type of file is not supported')
H
hypox64 已提交
28 29

    util.clean_tempfiles(tmp_init = False)
H
hypox64 已提交
30

H
hypox64 已提交
31 32 33 34 35 36 37 38
if __name__ == '__main__':
    try:
        main()
    except Exception as e:
        print('Error:',e)
        input('Please press any key to exit.\n')
        util.clean_tempfiles(tmp_init = False)
        exit(0)