SocAIty / face2face

Swap faces in images and videos. Create face embeddings. Enhance face image quality. Deploy as a web api.
MIT License
30 stars 2 forks source link

Failed Swap vídeo face #8

Open playdevv opened 1 week ago

playdevv commented 1 week ago

I'm using as a service, and I can change faces in images normally, but when I tried to change the face in a video I got an error in the console.

Swap face from imagens working Fine but vídeo give me some error

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/fast_task_api/core/JobManager.py", line 66, in process_job job.result = job.job_function(*job.job_params) File "/usr/local/lib/python3.10/dist-packages/face2face/server.py", line 92, in swap_video output_video = VideoFile().from_video_stream( File "/usr/local/lib/python3.10/dist-packages/media_toolkit/utils/dependency_requirements.py", line 18, in wrapper return func(args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/media_toolkit/core/video/video_file.py", line 178, in from_video_stream video_gen_wrapper = SimpleGeneratorWrapper(video_gen_wrapper, length=len(video_audio_stream)) TypeError: 'float' object cannot be interpreted as an integer

w4hns1nn commented 1 week ago

Hey playdevv,

thanks for reporting the issue. Face2Face works together with the media-toolkit package for video processing. It seems there's an issue with the loaded video so the framecount is then a float value instead of a integer. I suggest multiple fixes for that.

  1. Updating media-toolkit to cast the float value to integer when the video information is loaded.
  2. Update the simplegenerator and add there a second cast to int and "none" value check.

Are you so free to share the video file with me? Then i can specifcally check whats going on and will fix the problem for you until end of the week.

PS: are you working with the newest version?

In the meantime you can also just load the video and iter it frame by frame manually with media-toolkit or cv2

Thanks!