kijai / ComfyUI-LivePortraitKJ

ComfyUI nodes for LivePortrait
MIT License
518 stars 28 forks source link

Portrait video editing with stitching option ? #8

Open 3blackbar opened 4 days ago

3blackbar commented 4 days ago

In their example you can load input video, and just drive the mouth and eyes in the video, so it works with full video not just one image https://liveportrait.github.io/ https://liveportrait.github.io/src/video/video_animation_0_opt.mp4

kijai commented 4 days ago

Either I'm missing something or they didn't include the code for this. Unless it's the template option which I don't yet understand.

3blackbar commented 4 days ago

ok, heres how it can be done, - in relative mode wth source video input under source image input, so instead of feeding the node the same image, how about you feed frame from another video per each new frame ? So you have video feed as input frames too, face aligner should detect where the face is per new frame. Turn off retageting and enable relative mode ,cause in "relative" mode its using whole input image and its using one image for entire video, im sure this can be changed so its using consecutive video frames instead of one image , so in theory it should be able to use different image per every frame and not just one image ?

With this working we will be able to change what people say on the videos.

JZZZ1314 commented 3 days ago

I was able to perform a simple test, and by inferring about each frame of the edited video by talking about each frame of the driving video, I was able to get an effect close to that of the paper,Of course, this needs to wait for the official release of the full code, which is only experimental

ozworkz commented 3 days ago

ok, heres how it can be done, - in relative mode wth source video input under source image input, so instead of feeding the node the same image, how about you feed frame from another video per each new frame ? So you have video feed as input frames too, face aligner should detect where the face is per new frame. Turn off retageting and enable relative mode ,cause in "relative" mode its using whole input image and its using one image for entire video, im sure this can be changed so its using consecutive video frames instead of one image , so in theory it should be able to use different image per every frame and not just one image ?

With this working we will be able to change what people say on the videos.

Yes, with some tweaks in the code, reading each frame from the video input as a source image seems to work. Thanks!

3blackbar commented 3 days ago

Can You guys do pull request if You succesfully did it ?

Trimad commented 3 days ago

ok, heres how it can be done, - in relative mode wth source video input under source image input, so instead of feeding the node the same image, how about you feed frame from another video per each new frame ? So you have video feed as input frames too, face aligner should detect where the face is per new frame. Turn off retageting and enable relative mode ,cause in "relative" mode its using whole input image and its using one image for entire video, im sure this can be changed so its using consecutive video frames instead of one image , so in theory it should be able to use different image per every frame and not just one image ? With this working we will be able to change what people say on the videos.

Yes, with some tweaks in the code, reading each frame from the video input as a source image seems to work. Thanks!

Can you post your ComfyUI workflow please?

serkandyck commented 1 day ago

ok, heres how it can be done, - in relative mode wth source video input under source image input, so instead of feeding the node the same image, how about you feed frame from another video per each new frame ? So you have video feed as input frames too, face aligner should detect where the face is per new frame. Turn off retageting and enable relative mode ,cause in "relative" mode its using whole input image and its using one image for entire video, im sure this can be changed so its using consecutive video frames instead of one image , so in theory it should be able to use different image per every frame and not just one image ? With this working we will be able to change what people say on the videos.

Yes, with some tweaks in the code, reading each frame from the video input as a source image seems to work. Thanks!

Can you post your ComfyUI workflow please?

not perfect only 32 frame

https://gist.github.com/serkandyck/f937a540ca60fce8843d6c4242bfd869

cheezecrisp commented 17 hours ago

There is a dumb way to do this. Put the node 'image batch to image list'(Impack Pack) before source_image and put the node 'image list to image batch' after output. With this setting the workflow will produce a matrix of images, then pick up the images on the diagonal of the matrix, those images are exactly the frames what we want. But it's very inefficient, it will take much time to produce the matrix. Wanna know if there is a better way.

kijai commented 17 hours ago

The video editing is mostly working in the develop branch already, just some bugs to squash and optimizations to do.

skydam commented 5 hours ago

I can only see Source Image as input for the node (in Develop branch), no video option yet. What am I missing?

kijai commented 5 hours ago

I can only see Source Image as input for the node (in Develop branch), no video option yet. What am I missing?

The version in the develop branch takes both single image or a batch of images.

skydam commented 5 hours ago

Thanks! I'm looking at the new node, but a. what's the input node for crop_info? That's a new one, and b. which input node would one use as batch input for source image? BTW love your work!

skydam commented 5 hours ago

Sorry, beginner here. I'm seeing crop_info = self.cropper.crop_single_image(img_rgb), but Cropper seems commented out in #from .utils.cropper import Cropper

kijai commented 4 hours ago

Sorry, beginner here. I'm seeing crop_info = self.cropper.crop_single_image(img_rgb), but Cropper seems commented out in #from .utils.cropper import Cropper

It's a whole new structure in that version, there's separate node that does the detection and cropping, it outputs the crop info for the main node. You input your source to the cropper node, it can be single image or batch of images, then you input the driving video to the process node.

skydam commented 4 hours ago

Ah I see! Yes, found it: LivePortraitCropper. Thanks!

skydam commented 4 hours ago

It's working! The cropped images work fine. The full images is still a mess for me though. Not quite sure if I'm doing it wrong or if it's still work in progress.

skydam commented 3 hours ago

https://github.com/kijai/ComfyUI-LivePortraitKJ/assets/73529516/188c4279-8ea7-49a9-9e8b-fba82f1a8109

Maelstrom2014 commented 3 hours ago

LivePortrait_00008.mp4

Please post example! or screenshot of workflow.

skydam commented 3 hours ago

https://github.com/kijai/ComfyUI-LivePortraitKJ/assets/73529516/25f0c47d-c4e9-46d8-91b5-3df0f2829f20

This is what comes out of full_images, whereas the cropped (stabilised) images are as above.

skydam commented 3 hours ago

CleanShot 2024-07-10 at 00 08 27@2x

kijai commented 3 hours ago

CleanShot 2024-07-10 at 00 08 27@2x

What are you feeding for the source_image there? it should be the input video, not the crop

skydam commented 3 hours ago

THAT WAS IT! I fed the cropped image into source.

https://github.com/kijai/ComfyUI-LivePortraitKJ/assets/73529516/10b1ae04-013d-4ab7-a2c5-6ac27b8d301e

Maelstrom2014 commented 3 hours ago

need also a mask for pasting image.

Maelstrom2014 commented 3 hours ago

LivePortraitCropper still use CPU, takes 160sec, too long. I does not matter that i put CUDA in menu

kijai commented 3 hours ago

LivePortraitCropper still use CPU, takes 160sec, too long. I does not matter that i put CUDA in menu

Possibly you don't have onnx installed for GPU? Do you have onnxruntime-gpu installed? It's sometimes bit of a pain to get to work, for reference on my 4090 it's about 33it/s.

skydam commented 3 hours ago

I have 2.75it/s on my 3090/24gb