BadToBest / EchoMimic

Lifelike Audio-Driven Portrait Animations through Editable Landmark Conditioning
https://badtobest.github.io/echomimic.html
Apache License 2.0
2.82k stars 330 forks source link

Resize issue #183

Open TanvirHafiz opened 1 week ago

TanvirHafiz commented 1 week ago

I got this error:

Traceback (most recent call last): File "F:\EchoMimic\venv\lib\site-packages\gradio\queueing.py", line 624, in process_events response = await route_utils.call_process_api( File "F:\EchoMimic\venv\lib\site-packages\gradio\route_utils.py", line 323, in call_process_api output = await app.get_blocks().process_api( File "F:\EchoMimic\venv\lib\site-packages\gradio\blocks.py", line 2018, in process_api result = await self.call_function( File "F:\EchoMimic\venv\lib\site-packages\gradio\blocks.py", line 1567, in call_function prediction = await anyio.to_thread.run_sync( # type: ignore File "F:\EchoMimic\venv\lib\site-packages\anyio\to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "F:\EchoMimic\venv\lib\site-packages\anyio_backends_asyncio.py", line 2441, in run_sync_in_worker_thread return await future File "F:\EchoMimic\venv\lib\site-packages\anyio_backends_asyncio.py", line 943, in run result = context.run(func, args) File "F:\EchoMimic\venv\lib\site-packages\gradio\utils.py", line 846, in wrapper response = f(args, **kwargs) File "F:\EchoMimic\webgui.py", line 233, in generate_video final_output_path = process_video( File "F:\EchoMimic\webgui.py", line 169, in process_video face_img = cv2.resize(face_img, (width, height)) cv2.error: OpenCV(4.10.0) :-1: error: (-5:Bad argument) in function 'resize'

Overload resolution failed:

  • src is not a numerical tuple
  • Expected Ptr for argument 'src'

Seems to be an issue with resizing. but it shouldnt be. any help suggestion?

nitinmukesh commented 1 week ago

Try with command line first.

TanvirHafiz commented 1 week ago

Try with command line first.

i dont know how to do that and i dont want to run the interface like that either. the gradio is working fine. just this error relating to resizing

TanvirHafiz commented 6 days ago

okay so it seems that echomimic only supports square aspect ratios, so images need to be cut at 512 x 512 or some other square resolution. which is strange because it seems to have a image size slider. i wonder what that is for.

nitinmukesh commented 6 days ago

Yes 512 x 512. just ignore the slider.

csimlinger commented 4 days ago

I get the same error, also with square images. no matter if I use my own images or the official test images. In console it works great. Any idea how to solve the issue?

csimlinger commented 4 days ago

I found the solution.

Open webgui.py and change the part from line 162 to this:

# Crop and pad face_img
face_img = crop_and_pad(face_img, crop_rect)
if isinstance(face_img, tuple):
    face_img = face_img[0]  # Keep only the image part if crop_and_pad returns a tuple

# Crop and pad face_mask
face_mask = crop_and_pad(face_mask, crop_rect)
if isinstance(face_mask, tuple):
    face_mask = face_mask[0]  # Keep only the mask part if crop_and_pad returns a tuple

The reason it didn’t work was that crop_and_pad returned a tuple instead of a numpy.ndarray, causing an AttributeError when accessing .shape. Selecting only the first element resolved the issue.