ai-forever / ghost

A new one shot face swap approach for image and video domains
Apache License 2.0
1.25k stars 265 forks source link

Add ability to skip --target_faces_paths option #20

Closed netrunner-exe closed 2 years ago

netrunner-exe commented 2 years ago

Hey! Thank you very much for the work done, we hope that the code will continue to be developed and finalized. There is one question. In the description of the --target_faces_paths option, you noted that you can skip this option and then any face in the photo or video will be selected. Unfortunately, the ability to choose whether to use a face from a screenshot or to automatically select any face does not work. If you skip this parameter, then there will always be an error (for a photo or video)

List of source paths:  ['/content/sber-swap/examples/images/elon_musk.jpg']
List of target paths:  ['examples/images/1.png', 'examples/images/2.png', 'examples/images/3.png']
Traceback (most recent call last):
  File "inference.py", line 153, in <module>
    main(args)
  File "inference.py", line 88, in main
    img = crop_face(img, app, args.crop_size)[0]
  File "/content/sber-swap/utils/inference/image_processing.py", line 16, in crop_face
    image, _ = app.get(image_full, crop_size)
  File "/content/sber-swap/insightface_func/face_detect_crop_multi.py", line 58, in get
    metric='default')
  File "/usr/local/lib/python3.7/dist-packages/insightface/model_zoo/scrfd.py", line 204, in detect
    im_ratio = float(img.shape[0]) / img.shape[1]
AttributeError: 'NoneType' object has no attribute 'shape'

You can skip this parameter only if you remove default=['examples/images/1.png', 'examples/images/2.png', 'examples/images/3.png'], nargs='+'. from it. But then, if necessary, the parameter itself will not work ... Add the ability to choose whether to use automatic face selection or from a screenshot from the video.

Привет! Спасибо большое за проделанную работу, надеемся что код и дальше будет развиваться и дорабатываться. Есть один вопрос. В описании опции --target_faces_paths вы отметили что можно пропустить эту опцию и тогда будет выбираться любое лицо на фото или видео. К сожалению возможность выбирать - использовать лицо со скриншота или чтобы автоматически выбиралось любое лицо (если оно всего одно например) не работает. Если скипнуть этот параметр то всегда (для фото или видео) будет ошибка. Скипнуть этот параметр можно только если убрать из него default=['examples/images/1.png', 'examples/images/2.png', 'examples/images/3.png'], nargs='+'. Но тогда если будет нужно - не будет работать сам параметр...Добавьте возможность выбирать, использовать автоматический выбор лица или со скриншота с видео.

AlexanderGroshev commented 2 years ago

Hi @netrunner-exe , thanks for the feedback! We fixed this issue, you can check updated inference.py or change default value to default=[].

Привет, спасибо за ваш отзыв! Мы исправили эту проблему, можете проверить обновленный inference.py или поменять значение на default=[].