Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inswapper does not fail gracefully when targeted index in UI is higher than number of faces detected in the image. #19

Open
ujl123 opened this issue Feb 16, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ujl123
Copy link

ujl123 commented Feb 16, 2024

Read Troubleshoot

[x] I confirm that I have read the Troubleshoot guide before making this issue.

Describe the problem
When you try to target a face index that is greater than the actual number of faces detected, This is very easy to replicate. If you are swapping an image with x numbers of faces, in " Target Image Index " set it to a number greater than x.

Proposal: This should instead skip and move on to the next task rather than throwing an error and halting.

Full Console Log
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
inswapper-shape: [1, 3, 128, 128]
Source faces: 1
Target faces: 2
Replacing specific face(s) in the target image with specific face(s) from the source image
Traceback (most recent call last):
File "C:\Fooocus inswapper\Fooocus-inswapper\modules\async_worker.py", line 860, in worker
handler(task)
File "C:\Fooocus inswapper\Fooocus-inswapper\venv\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\Fooocus inswapper\Fooocus-inswapper\venv\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\Fooocus inswapper\Fooocus-inswapper\modules\async_worker.py", line 812, in handler
imgs = perform_face_swap(imgs, inswapper_source_image, inswapper_target_image_index)
File "C:\Fooocus inswapper\Fooocus-inswapper\modules\face_swap.py", line 14, in perform_face_swap
result_image = process([source_image], item, "-1", f"{int(inswapper_target_image_index)}", "../inswapper/checkpoints/inswapper_128.onnx")
File "C:\Fooocus inswapper\Fooocus-inswapper\inswapper\swapper.py", line 179, in process
raise ValueError(f"Target index {target_index} is higher than the number of faces in the target image")
ValueError: Target index 2 is higher than the number of faces in the target image

@machineminded machineminded self-assigned this Feb 16, 2024
@machineminded machineminded added the bug Something isn't working label Feb 16, 2024
@machineminded
Copy link
Owner

machineminded commented Feb 16, 2024

Thanks for the report. Been meaning to get this one recorded as an issue and resolved. Should be an easy enough fix.

@machineminded
Copy link
Owner

In general I think index out of bounds errors need addressed because sometimes inswapper is enabled, but there is not a face to swap so it fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants