goberoi/faceit

faceit.py convert throws error if imagemagick not installed (if running GAN model)

tauhlim opened this issue · 2 comments

Running faceit.py convert throws error if ImageMagick is not installed. moviepy states that ImageMagick is required for writing text, and more specifically is required for TextClip. Suggest updating requirements.txt or making text optional.

(tensorflow_p36) ubuntu@instance-1:~/GAN/faceit$ python3.6 faceit.py convert stark_to_hulk stark_suitup.mp4 --start 40 --duration 55 --side-by-side --use-gan --face-filter --width 800
Using TensorFlow backend.

Loading Model from Model_GAN plugin...
Discriminator models loaded.
Generator models loaded.
Loading Convert from Convert_GAN plugin...
Traceback (most recent call last):
  File "/home/ubuntu/miniconda3/envs/tensorflow_p36/lib/python3.6/site-packages/moviepy/video/VideoClip.py", line 1164, in __init__
    subprocess_call(cmd, verbose=False)
  File "/home/ubuntu/miniconda3/envs/tensorflow_p36/lib/python3.6/site-packages/moviepy/tools.py", line 42, in subprocess_call
    proc = sp.Popen(cmd, **popen_params)
  File "/home/ubuntu/miniconda3/envs/tensorflow_p36/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/home/ubuntu/miniconda3/envs/tensorflow_p36/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'unset': 'unset'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "faceit.py", line 365, in <module>
    faceit.convert(args.video, duration = args.duration, swap_model = args.swap_model, face_filter = args.face_filter, start_time = args.start_time, use_gan = args.use_gan, photos = args.photos, crop_x = args.crop_x, width = args.width, side_by_side = args.side_by_side)
  File "faceit.py", line 274, in convert
    video = add_caption("Original", video)
  File "faceit.py", line 269, in add_caption
    text = (TextClip(caption, font='Amiri-regular', color='white', fontsize=80).
  File "/home/ubuntu/miniconda3/envs/tensorflow_p36/lib/python3.6/site-packages/moviepy/video/VideoClip.py", line 1173, in __init__
    raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:

[Errno 2] No such file or directory: 'unset': 'unset'.

.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect

Can verify that commenting out lines to add_caption avoid this error

        # Stack clips side by side
        if side_by_side:
            def add_caption(caption, clip):
                text = (TextClip(caption, font='Amiri-regular', color='white', fontsize=80).
                        margin(40).
                        set_duration(clip.duration).
                        on_color(color=(0,0,0), col_opacity=0.6))
                return CompositeVideoClip([clip, text])
            #video = add_caption("Original", video)
            #new_video = add_caption("Swapped", new_video)                
            final_video = clips_array([[video], [new_video]])
        else:
            final_video = new_video

Running command without
--side-by-side
option worked for me

python faceit.py convert fallon_to_oliver fallon_emmastone.mp4 --start 40 --duration 55