YuvalNirkin / fsgan

FSGAN - Official PyTorch Implementation
https://nirkin.com/fsgan
Creative Commons Zero v1.0 Universal
752 stars 147 forks source link

python swap.py error #3

Closed molo32 closed 4 years ago

molo32 commented 4 years ago

when i run to swap a face it gives an error

i am using python3 in linux

cd fsgan/inference
python swap.py ../docs/examples/shinzo_abe.mp4 -t ../docs/examples/conan_obrien.mp4 -o . --finetune --finetune_save --seg_remove_mouth
=> using GPU devices: 0
=> Loading face pose model: "hopenet_robust_alpha1.pth"...
=> Loading face landmarks model: "hr18_wflw_landmarks.pth"...
=> Loading face segmentation model: "celeba_unet_256_1_2_segmentation_v2.pth"...
=> Loading face reenactment model: "nfv_msrunet_256_1_2_reenactment_v2.1.pth"...
=> Loading face completion model: "ijbc_msrunet_256_1_2_inpainting_v2.pth"...
=> Loading face blending model: "ijbc_msrunet_256_1_2_blending_v2.pth"...
=> Cropping video sequences from video: "conan_obrien.mp4"...
Could not find encoder for codec id 27: Encoder not found
100% 150/150 [00:01<00:00, 84.60it/s]
=> Computing face poses for video: "conan_obrien_seq00.mp4"...
Traceback (most recent call last):
  File "/content/swap.py", line 498, in <module>
    main(**vars(parser.parse_args()))
  File "/content/swap.py", line 492, in main
    face_swapping(source[0], target[0], output, select_source, select_target)
  File "/content/swap.py", line 237, in __call__
    source_cache_dir, source_seq_file_path, _ = self.cache(source_path)
  File "/content/fsgan/preprocess/preprocess_video.py", line 463, in cache
    self.process_pose(input_path, output_dir, seq_file_path)
  File "/content/fsgan/preprocess/preprocess_video.py", line 242, in process_pose
    in_vid = VideoInferenceDataset(curr_vid_path, transform=img_transforms)
  File "/content/fsgan/datasets/video_inference_dataset.py", line 29, in __init__
    self.width, self.height, self.total_frames, self.fps = get_video_info(vid_path)
  File "/content/fsgan/utils/video_utils.py", line 223, in get_video_info
    return get_media_info(vid_path)
  File "/content/fsgan/utils/video_utils.py", line 206, in get_media_info
    probe = ffmpeg.probe(media_path)
  File "/usr/local/lib/python3.6/dist-packages/ffmpeg/_probe.py", line 23, in probe
    raise Error('ffprobe', out, err)
ffmpeg._run.Error: ffprobe error (see stderr output for detail)
shiyingZhang90 commented 4 years ago

Yeah, I got the same error as well.

shiyingZhang90 commented 4 years ago

I believe the issue Could not find encoder for codec id 27: Encoder not found. so there is no "shinzo_abe_seq00.mp4" generated in the output directory -- that causing the probe error. Not found why have such encoder error yet

shiyingZhang90 commented 4 years ago

Seems like my installed opencv still doesn't include avc1 as encoder. @YuvalNirkin is other video format also supported? I tried "mp4v" instead of 'avc1'. but get following errors:

Traceback (most recent call last): File "swap.py", line 498, in main(*vars(parser.parse_args())) File "swap.py", line 492, in main face_swapping(source[0], target[0], output, select_source, select_target) File "swap.py", line 237, in call source_cache_dir, source_seq_filepath, = self.cache(source_path) File "/usr/local/google/home/ellaz/github/data/dev/projects/fsgan/preprocess/preprocess_video.py", line 464, in cache self.process_pose(input_path, output_dir, seq_file_path) File "/usr/local/google/home/ellaz/github/data/dev/projects/fsgan/preprocess/preprocess_video.py", line 251, in process_pose poses = self.facepose(frame).div(99.) # Yaw, Pitch, Roll File "/usr/local/google/home/ellaz/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call result = self.forward(input, *kwargs) File "/usr/local/google/home/ellaz/github/data/dev/projects/fsgan/models/hopenet.py", line 90, in forward yaw_predicted = torch.sum(yaw_predicted self.idx_tensor, axis=1).unsqueeze(1) * 3 - 99 TypeError: sum() received an invalid combination of arguments - got (Tensor, axis=int), but expected one of:

YuvalNirkin commented 4 years ago

@molo32 @shiyingZhang90 This is a missing encoder issue. Other encoders might work as well but might produce inferior results.

Did you install OpenCV from source like in the installation guide?

shiyingZhang90 commented 4 years ago

Yeah, I installed OpenCV from source. yet, still missing avc1 as encoder. I do check cmake configuration and OpenCV do build ffmpeg, setting as below: --   Video I/O: --     DC1394:                      YES (2.2.5) --     FFMPEG:                      YES --       avcodec:                   YES (58.80.100) --       avformat:                  YES (58.42.101) --       avutil:                    YES (56.42.102) --       swscale:                   YES (5.6.101) --       avresample:                YES (4.0.0) --     GStreamer:                   NO --     v4l/v4l2:                    YES (linux/videodev2.h) I also check ffmpeg independently and it do have libx264 encoder working. I'm wondering whether it's due to python3 working with openCV. Since after import cv into python3, it will complain cannot find avc1 encoder

jjandnn commented 4 years ago

@molo32 @shiyingZhang90 这是一个老问题,你们测试的环境应该不是新的。如果不是新环境,务必先 ‘’pip uninstall opencv-python -y ‘’,然后再 编译安装 opencv 。 This is an old problem and the environment you are testing should not be new. If it is not a new environment, be sure to first ‘’PIP uninstall opencv-python -y‘’ and then compile and install opencv @YuvalNirkin 程序很不错,效率非常高,很容易做进一步的开发结合。自然光环境下的人物很生动。 感谢,祝好! The program is very good, very efficient, very easy to do further development combined with the natural light environment of the character is very vivid thank you, good!

ak9250 commented 4 years ago

@jjandnn did you try to compile and install opencv in google colab? I am facing the same issue

shiyingZhang90 commented 4 years ago

@jjandnn Thanks for suggestion. Yet, when I compile opencv from source and using python to import cv2, I got undefined symbol error: ImportError: /usr/lib/x86_64-linux-gnu/libopencv_text.so.4.1: undefined symbol: _ZN2cv3dnn14dnn4_v201909023Net8setInputERKNS_11_InputArrayERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEdRKNS_7Scalar_IdEE Any idea?

jjandnn commented 4 years ago

@ak9250 @shiyingZhang90 我测试完成了。colab运行,必须把opencv单独编译在/content目录下下。如果编译到谷歌云盘,由于my drive空格,路径有问题,于是就比较麻烦了。其余部分直接装在云盘。 My test is complete. To run colab, opencv must be compiled separately in the / content directory. If you compile to Google Cloud Disk, due to my drive space, there is a problem with the path, so it is more troublesome. The rest is directly installed in the cloud disk. 代码如下code show as below:

must p100 《——————****important

!nvidia-smi

!rm -rf sample_data from google.colab import drive drive.mount('/content/drive')

1,云盘源码安装(首次需要,之后使用无需再装Need for the first time, after the use of no need to install

) !nvcc -V %cd /content/drive/My Dirve !mkdir -p fsganLab/fshome %cd /content/drive/My Drive/fsganLab/fshome !git clone https://github.com/YuvalNirkin/fsgan.git !git clone https://github.com/YuvalNirkin/face_detection_dsfd

问官方要的下载文件授权,放在fshome下,运行得到权重文件夹 weights,里面共17个模型文件

!python download_fsgan_models.py -m v1 !python download_fsgan_models.py -m v2

由于 colab 空格问题,重新组织下目录结构

!mv /content/drive/My\ Drive/fsganLab/fshome/weights /content/drive/My\ Drive/fsganLab !cp /content/drive/My\ Drive/fsganLab/fshome/fsgan/inference/swap.py .

2,其余依赖(中间需要按一次回车。以下依赖为每次使用都需要重新安装)

!apt install libv4l-dev libxvidcore-dev libx264-dev !pip install yacs tensorboardX ffmpeg-python face_alignment !pip uninstall opencv-python -y

3, 编译安装 opencv

%cd /content

!wget -O opencv.zip https://github.com/opencv/opencv/archive/4.3.0.zip

!cp /content/drive/My\ Drive/opencv.zip . !unzip opencv.zip !rm opencv.zip %cd /content/opencv-4.3.0 !mkdir build %cd /content/opencv-4.3.0/build !cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") \ -D ENABLE_FAST_MATH=ON \ -D INSTALL_PYTHON_EXAMPLES=OFF \ -D INSTALL_C_EXAMPLES=OFF \ -D OPENCV_ENABLE_NONFREE=OFF \ -D CMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") \ -D PYTHON_EXECUTABLE=$(which python) \ -D PYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ -D PYTHON_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \ -D BUILD_EXAMPLES=OFF \ -D BUILD_JPEG=ON .. !make -j8 !sudo make install !sudo ldconfig

结果: http://changed-media.test.upcdn.net/image/test-fsgan.png

zhuhaozh commented 4 years ago

Met the same issue:

Could not find encoder for codec id 27: Encoder not found

A possible solution found here

Here my solution: I did not install OpenCV followed the installation guide, but change all

cv2.VideoWriter_fourcc(*'avc1')

to

cv2.VideoWriter_fourcc(*'mp4v')

maybe you should change some other code if you meet the similar problem.

jjandnn commented 4 years ago

@shiyingZhang90 @ak9250 要是你们可以接受MP4v的编码,@zhuhaozh 的方式是很好的办法,以前很多程序,比如spleeter,yolo等,都是用这个办法解决opencv、ffmpeg编码问题的。对于256的视频,作者是研发,会比较在意长期发展,画面微调的质量。我们纯粹应用的话,其实区别真不大。 这个办法的另一个好处是colab原装的大部分程序都不用动,这样就省时间了。 If you can accept MP4v encoding, the method of @zhuhaozh is a good way. Many previous programs, such as spleeter, yolo, etc., used this method to solve the opencv and ffmpeg encoding problems. For the 256 video, the author is research and development, will be more concerned about the long-term development, the quality of the picture fine-tuning. In our pure application, the difference is really not that great.

Another advantage of this method is that most of the original Colab programs do not need to be used, which saves time.

5files(2020.4.25): avc1-mp4v-files.zip

如果大家还是搞不定,晚些我发colab。 If you still can't, I'll upload colab later。

wangchao0899 commented 4 years ago

@jjandnn Thank you for your Colab practice, I have sorted out your code here。 image fsganlab.zip

jjandnn commented 4 years ago

@wangchao0899 辛苦你了。但可能你得先删了那个版本,我测了还有问题,就是程序自动完结退出。 现在我发的是不装opencv的快速完全不报错版。一步到位!麻烦你帮我再翻译一个英文版给大家。像刚才那样,哈哈哈。

Hard work you but you may have to delete that version, I tested and there are problems, is the program automatically end exit。 now I send is not installed opencv fast version of the wrong step in place! Please help me to translate an English version for everyone like just now, hahaha。 my English is poor! Ps:我去除opencv的安装是因为opencv-python够了,这一步在colab上花半小时,对于测试基本性能,太折磨。k80、T4,ok行;P4溢出。另外,MP4v和avc1的区别是在微调这个环节MP4v在面部衔接处,尤其是光影反差大的时候,会有少量闪烁。大家自己看。 Ps: I removed the installation of opencv because opencv-python is enough. This step took half an hour on colab. To test the basic performance, it was too much torment. Line k80 and T4ok;p4 overflow. In addition, the difference between MP4v and avc1 is that there is a small amount of flicker when MP4v is fine-tuned at the interface of the face, especially when the contrast between light and shadow is large. Everyone sees it for themselves. 注意,无论src视频,还是dst视频都不能有白场白闪的帧,必须去除,否则程序会从白闪后开始转换,之前的帧不会fs。 Note that neither SRC video nor DST video can have white field white flash frame, must be removed, otherwise the program will start to convert from the white flash, the previous frame will not fs。

wangchao0899 commented 4 years ago

好的,没有问题,我这边是晚上,可能得明天上午我测试一遍就发咯~ Okay, no problem, it's night on my side, I might have to test it tomorrow morning and release it ~ THX your work~

发送自 Windows 10 版邮件应用

发件人: 杜俊 发送时间: 2020年4月22日 17:30 收件人: YuvalNirkin/fsgan 抄送: wangchao0899; Mention 主题: Re: [YuvalNirkin/fsgan] python swap.py error (#3)

@wangchao0899 你先删了那个版本,我测了还有问题。现在我发的是不装opencv的快速无错版。一步到位!麻烦你帮我再翻译一个英文版给大家。像刚才那样,哈哈哈。 FSGAN_conda_mp4v_colab.zip You first deleted that version, I tested and there are problems now I send is not installed opencv fast version of the wrong step in place! Please help me to translate an English version for everyone like just now, hahaha。 my English is poor! — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

wangchao0899 commented 4 years ago

@jjandnn Nice Work,Brother~ I have work it out~ image

fsganlab_update1.zip

YuvalNirkin commented 4 years ago

@wangchao0899 Thank you for the work on the colab but the excessive downloading of the models blocks anyone else from downloading them: image Please stop for now until I'll find a better way to host the models.

molo32 commented 4 years ago

try running fsganlab_update1.zip but it gives me a root path error. I don't understand why, I have everything in place, someone has the same problem.

err colab fsgan

fpandza commented 4 years ago

Somewhat related to solution by wangchao0899, I notice you use download script to get both v1 and v2 models. Is there any value in downloading v1 models? I downloaded just v2 and the script seems to be performing decently, would v1 models improve anything? And be used at all for that matter?

shiyingZhang90 commented 4 years ago

@jjandnn 杜神,我试了你的colab,但在使用的时候出现了下面这个错误: Traceback (most recent call last): File "swap.py", line 498, in main(**vars(parser.parse_args())) File "swap.py", line 494, in main batch(source, target, output, face_swapping, postfix='.mp4', skip_existing=True) File "/content/drive/My Drive/fsganLab/fshome/fsgan/utils/batch.py", line 46, in main assert target_paths is None or len(target_paths) > 0, 'Found 0 target paths' AssertionError: Found 0 target paths Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/local/lib/python3.7/multiprocessing/popen_fork.py", line 28, in poll Process FaceSwappingRenderer-1: KeyboardInterrupt Traceback (most recent call last): File "/usr/local/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/content/drive/My Drive/fsganLab/fshome/fsgan/utils/video_renderer.py", line 85, in run task = self._input_queue.get() File "/usr/local/lib/python3.7/multiprocessing/queues.py", line 94, in get res = self._recv_bytes() File "/usr/local/lib/python3.7/multiprocessing/connection.py", line 216, in recv_bytes buf = self._recv_bytes(maxlength) File "/usr/local/lib/python3.7/multiprocessing/connection.py", line 407, in _recv_bytes buf = self._recv(4) File "/usr/local/lib/python3.7/multiprocessing/connection.py", line 379, in _recv chunk = read(handle, remaining) KeyboardInterrupt

shiyingZhang90 commented 4 years ago

@jjandnn 解決了,是colab中的target video需要修改。 have you guys tried with your own video yet? I get following error when I upload my own mp4 file, is there any requirement to mp4 videos?

Traceback (most recent call last): File "/usr/local/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/content/drive/My Drive/fsganLab/fshome/fsgan/utils/video_renderer.py", line 157, in run assert frame_bgr is not None, f'Failed to read frame {i} from input video: "{self._in_vid_path}"' AssertionError: Failed to read frame 43 from input video: "/content/drive/My Drive/fsganLab/fshome/fsgan/docs/examples/model1.mp4"

wangchao0899 commented 4 years ago

@wangchao0899 Thank you for the work on the colab but the excessive downloading of the models blocks anyone else from downloading them: image Please stop for now until I'll find a better way to host the models.

Maybe Baidu Yun can solve this problem~~

wangchao0899 commented 4 years ago

try running fsganlab_update1.zip but it gives me a root path error. I don't understand why, I have everything in place, someone has the same problem.

err colab fsgan

image 原因是你的 weights 目录 需要放到fsganlab下,而不是放在fshome下面 image The reason is that your weights directory needs to be placed under fsganlab, not under fshome image

jjandnn commented 4 years ago

@wangchao0899 Thank you for the work on the colab but the excessive downloading of the models blocks anyone else from downloading them: image Please stop for now until I'll find a better way to host the models.

Maybe Baidu Yun can solve this problem~~

作者可能不是这个意思,虽然是开源,但是产权是有讲法的。之所以大家要登记授权,是因为现阶段fs技术有争议,滥用模型承担法律责任必须自负,作者的这个方式是对他的团队的保护,也是对于所有同行在该领域工作开发权利的一种争取。 The author may not be this meaning, though it is open source, but the property is threatened-seem is everyone to register license, because the present controversial fs technology, must bear legal responsibility conceited abuse model, the author of this way is the protection of his team, and for all their peers in the field work to develop a struggle for rights。

jjandnn commented 4 years ago

Somewhat related to solution by wangchao0899, I notice you use download script to get both v1 and v2 models. Is there any value in downloading v1 models? I downloaded just v2 and the script seems to be performing decently, would v1 models improve anything? And be used at all for that matter?

今天凌晨v1的下载resp动了,要下载根据作者邮件直接去谷歌分享里拉,就用v2,这应该是作者推荐的。 The download resp of v1 was moved early this morning. If you want to download according to the author's email, go directly to Google to share lira, use v2, which should be recommended by the author

wangchao0899 commented 4 years ago

Somewhat related to solution by wangchao0899, I notice you use download script to get both v1 and v2 models. Is there any value in downloading v1 models? I downloaded just v2 and the script seems to be performing decently, would v1 models improve anything? And be used at all for that matter?

Sorry, I can’t answer this question because I didn’t do more testing for this I download them all~~

shiyingZhang90 commented 4 years ago

@jjandnn 在你最新的colab里面如果使用自己上传的video会遇到如下的error,请教

=> Face swapping: "model2_seq00.mp4" -> "model3_seq00.mp4"... 100% 20/20 [01:02<00:00, 3.15s/batches] Process FaceSwappingRenderer-1: Traceback (most recent call last): File "/usr/local/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/content/drive/My Drive/fsganLab/fshome/fsgan/utils/video_renderer.py", line 157, in run assert frame_bgr is not None, f'Failed to read frame {i} from input video: "{self._in_vid_path}"' AssertionError: Failed to read frame 303 from input video: "/content/drive/My Drive/fsganLab/fshome/fsgan/docs/examples/model3.mp4"

jjandnn commented 4 years ago

@shiyingZhang90 @wangchao0899 我在上面根正了v2,实在不好意思,我在%%writefile crop_video这个文件的时候复制路径,贴了image那个路径。由于我的机子文件,已经写过,不用这步,所以不报错。你们用我刚上传的V2再来一遍,防止以后用到image那个文件的时候出错。下面的mp4目标我也改回作者的样本文件名了,哈哈,我用各种帧率码率的视频在测试程序的兼容。 I rooted v2 on it. I'm really embarrassed. I copied the path when I copied the file %% writefile crop_video and pasted the image path. Since my machine file has already been written, this step is not necessary, so no error is reported. You use the V2 that I just uploaded to do it again to prevent errors when using the image file in the future. I also changed the sample file name of the author to the mp4 target below, haha, I used videos of various frame rates and bit rates to test the compatibility of the program. FSGAN(conda版v2).zip PS:大家务必删干净重装一下,防止那两个文件出错,因为我同时在改几个程序,眼睛看花了。至于v1模型的resp,我在colab里就不写了,直接v2。要用,自己去申请,转存共享。 PS: Everyone must delete it and reinstall it to prevent the two files from making mistakes, because I am changing several programs at the same time. As for the resp of the v1 model, I will not write it in colab, just v2. To use it, apply for it yourself and transfer it for sharing. file

shiyingZhang90 commented 4 years ago

@jjandnn 我用了最新更新的v2,但用新的video,仍然有之前的问题。 我把测试用的video发你163邮箱了便于复现,如果不能repeat请告知,谢谢

=> Face swapping: "model2_seq00.mp4" -> "model3_seq00.mp4"... 100% 20/20 [01:02<00:00, 3.15s/batches] Process FaceSwappingRenderer-1: Traceback (most recent call last): File "/usr/local/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run() File "/content/drive/My Drive/fsganLab/fshome/fsgan/utils/video_renderer.py", line 157, in run assert frame_bgr is not None, f'Failed to read frame {i} from input video: "{self._in_vid_path}"' AssertionError: Failed to read frame 303 from input video: "/content/drive/My Drive/fsganLab/fshome/fsgan/docs/examples/model3.mp4"

wangchao0899 commented 4 years ago

@jjandnn Just after class, I have time to test the V2 version in the afternoon

jjandnn commented 4 years ago

@shiyingZhang90 的问题的已经解决,视频原始素材问题,在此提醒大家,和其他很多gan模型一样,尽可能使用25帧/秒的素材。23帧不要用。 The problem of @ shiyingZhang90 has been solved, the original material problem of the video, here to remind everyone, like many other gan models, use 25 frames / second material as much as possible. Do not use 23 frames.

Colab updata(follow MR.YN): FSGAN(conda版V2020_4_25).zip

YuvalNirkin commented 4 years ago

I added an optional parameter "encoder_codec" for solving the issue with the missing encoder.

About the issue of failure reading specific frames, first encode the videos using standard encoding before feeding them to the algorithm:

ffmpeg -i input.mp4 -r 25 output.mp4

This thread has gone off topic, open new relevant threads if necessary.

houxuedong commented 4 years ago

when i run to swap a face it gives an error

i am using python3 in linux

cd fsgan/inference
python swap.py ../docs/examples/shinzo_abe.mp4 -t ../docs/examples/conan_obrien.mp4 -o . --finetune --finetune_save --seg_remove_mouth
=> using GPU devices: 0
=> Loading face pose model: "hopenet_robust_alpha1.pth"...
=> Loading face landmarks model: "hr18_wflw_landmarks.pth"...
=> Loading face segmentation model: "celeba_unet_256_1_2_segmentation_v2.pth"...
=> Loading face reenactment model: "nfv_msrunet_256_1_2_reenactment_v2.1.pth"...
=> Loading face completion model: "ijbc_msrunet_256_1_2_inpainting_v2.pth"...
=> Loading face blending model: "ijbc_msrunet_256_1_2_blending_v2.pth"...
=> Cropping video sequences from video: "conan_obrien.mp4"...
Could not find encoder for codec id 27: Encoder not found
100% 150/150 [00:01<00:00, 84.60it/s]
=> Computing face poses for video: "conan_obrien_seq00.mp4"...
Traceback (most recent call last):
  File "/content/swap.py", line 498, in <module>
    main(**vars(parser.parse_args()))
  File "/content/swap.py", line 492, in main
    face_swapping(source[0], target[0], output, select_source, select_target)
  File "/content/swap.py", line 237, in __call__
    source_cache_dir, source_seq_file_path, _ = self.cache(source_path)
  File "/content/fsgan/preprocess/preprocess_video.py", line 463, in cache
    self.process_pose(input_path, output_dir, seq_file_path)
  File "/content/fsgan/preprocess/preprocess_video.py", line 242, in process_pose
    in_vid = VideoInferenceDataset(curr_vid_path, transform=img_transforms)
  File "/content/fsgan/datasets/video_inference_dataset.py", line 29, in __init__
    self.width, self.height, self.total_frames, self.fps = get_video_info(vid_path)
  File "/content/fsgan/utils/video_utils.py", line 223, in get_video_info
    return get_media_info(vid_path)
  File "/content/fsgan/utils/video_utils.py", line 206, in get_media_info
    probe = ffmpeg.probe(media_path)
  File "/usr/local/lib/python3.6/dist-packages/ffmpeg/_probe.py", line 23, in probe
    raise Error('ffprobe', out, err)
ffmpeg._run.Error: ffprobe error (see stderr output for detail)
`

when i run to swap a face it gives an error

i am using python3 in linux

cd fsgan/inference python swap.py ../docs/examples/shinzo_abe.mp4 -t ../docs/examples/conan_obrien.mp4 -o . --finetune --finetune_save --seg_remove_mouth

=> using GPU devices: 0 => Loading face pose model: "hopenet_robust_alpha1.pth"... => Loading face landmarks model: "hr18_wflw_landmarks.pth"... => Loading face segmentation model: "celeba_unet_256_1_2_segmentation_v2.pth"... => Loading face reenactment model: "nfv_msrunet_256_1_2_reenactment_v2.1.pth"... => Loading face completion model: "ijbc_msrunet_256_1_2_inpainting_v2.pth"... => Loading face blending model: "ijbc_msrunet_256_1_2_blending_v2.pth"... => Cropping video sequences from video: "conan_obrien.mp4"... Could not find encoder for codec id 27: Encoder not found 100% 150/150 [00:01<00:00, 84.60it/s] => Computing face poses for video: "conan_obrien_seq00.mp4"... Traceback (most recent call last): File "/content/swap.py", line 498, in main(**vars(parser.parse_args())) File "/content/swap.py", line 492, in main face_swapping(source[0], target[0], output, select_source, select_target) File "/content/swap.py", line 237, in call source_cache_dir, source_seq_filepath, = self.cache(source_path) File "/content/fsgan/preprocess/preprocess_video.py", line 463, in cache self.process_pose(input_path, output_dir, seq_file_path) File "/content/fsgan/preprocess/preprocess_video.py", line 242, in process_pose in_vid = VideoInferenceDataset(curr_vid_path, transform=img_transforms) File "/content/fsgan/datasets/video_inference_dataset.py", line 29, in init self.width, self.height, self.total_frames, self.fps = get_video_info(vid_path) File "/content/fsgan/utils/video_utils.py", line 223, in get_video_info return get_media_info(vid_path) File "/content/fsgan/utils/video_utils.py", line 206, in get_media_info probe = ffmpeg.probe(media_path) File "/usr/local/lib/python3.6/dist-packages/ffmpeg/_probe.py", line 23, in probe raise Error('ffprobe', out, err) ffmpeg._run.Error: ffprobe error (see stderr output for detail)

set encoder_codec= 'mp4v', python swap.py ../docs/examples/shinzo_abe.mp4 -t ../docs/examples/conan_obrien.mp4 -o . -ec mp4v --finetune --finetune_save --seg_remove_mouth

mzietlow commented 4 years ago

I too ran into the ffprobe error and none of the info given here (anywhere really) was able to resolve my problem.

Finally I figured that the cmake (given in ubuntu installation guide) for building OpenCV from source was failing (silently) on my AWS instance.

Lacking of another place, if someone else runs into ffprobe errors, might be worth your time to closely check your logs during OpenCV installation.

I solved my error by explicitly referencing python3 executables in the OpenCV cmake part, such that:

wget -O opencv.zip https://github.com/opencv/opencv/archive/4.3.0.zip
unzip opencv.zip
rm opencv.zip
cd opencv-4.3.0
mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D ENABLE_FAST_MATH=ON \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D WITH_FFMPEG=ON \
-D BUILD_EXAMPLES=OFF \
-D BUILD_JPEG=ON \
-D BUILD_opencv_python3=yes \
-D PYTHON_LIBRARY=$PYTHON_LIBRARY \
-D CMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") \
-D PYTHON3_EXECUTABLE=$PYTHON_EXECUTABLE \
-D PYTHON3_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") ..

make -j8
sudo make install
sudo ldconfig
willyzw1221 commented 3 years ago

闪烁

你好

@wangchao0899 辛苦你了。但可能你得先删了那个版本,我测了还有问题,就是程序自动完结退出。 现在我发的是不装opencv的快速完全不报错版。一步到位!麻烦你帮我再翻译一个英文版给大家。像刚才那样,哈哈哈。

Hard work you but you may have to delete that version, I tested and there are problems, is the program automatically end exit。 now I send is not installed opencv fast version of the wrong step in place! Please help me to translate an English version for everyone like just now, hahaha。 my English is poor! Ps:我去除opencv的安装是因为opencv-python够了,这一步在colab上花半小时,对于测试基本性能,太折磨。k80、T4,ok行;P4溢出。另外,MP4v和avc1的区别是在微调这个环节MP4v在面部衔接处,尤其是光影反差大的时候,会有少量闪烁。大家自己看。 Ps: I removed the installation of opencv because opencv-python is enough. This step took half an hour on colab. To test the basic performance, it was too much torment. Line k80 and T4ok;p4 overflow. In addition, the difference between MP4v and avc1 is that there is a small amount of flicker when MP4v is fine-tuned at the interface of the face, especially when the contrast between light and shadow is large. Everyone sees it for themselves. 注意,无论src视频,还是dst视频都不能有白场白闪的帧,必须去除,否则程序会从白闪后开始转换,之前的帧不会fs。 Note that neither SRC video nor DST video can have white field white flash frame, must be removed, otherwise the program will start to convert from the white flash, the previous frame will not fs。

你好,请问 AVC1 会出现闪烁的问题吗,我目前在用MP4V编码,闪烁问题严重