AliaksandrSiarohin / first-order-model

This repository contains the source code for the paper First Order Motion Model for Image Animation
https://aliaksandrsiarohin.github.io/first-order-model-website/
MIT License
14.42k stars 3.2k forks source link

Crop is distorted in crop-video.py #134

Open boraturant opened 4 years ago

boraturant commented 4 years ago

Hi,

In crop-video.py, cropped content is distorted with the following code, where w and h is different.

Is this something intentional helping the model?

return f'ffmpeg -i {inp} -ss {start} -t {time} -filter:v "crop={w}:{h}:{left}:{top}, scale=256:256" crop.mp4'

Thanks

AliaksandrSiarohin commented 4 years ago

Hi, what do you mean distorted?

boraturant commented 4 years ago

return f'ffmpeg -i {inp} -ss {start} -t {time} -filter:v "crop={w}:{h}:{left}:{top}, scale=256:256" crop.mp4'

say that w and h is calculated as 300 and 400 respectively. You are scaling a rectangle are into a square (256, 256).

return f'ffmpeg -i {inp} -ss {start} -t {time} -filter:v "crop={300}:{400}:{left}:{top}, scale=256:256" crop.mp4'

AliaksandrSiarohin commented 4 years ago

Can you please send an example video where w and h are different?

boraturant commented 4 years ago

just to confirm, input video to crop-video.py is not square, does it have to be square?

AliaksandrSiarohin commented 4 years ago

No, rectangle is also fine. Why?

Honlan commented 4 years ago

I think boraturant means that the cropped videos may not follow the original aspect ratios.

MentalGear commented 4 years ago

Noticed the same issue with aspect ratio stretching. It seems like the resize function stretches the aspect ratio if the original image's width and height are not equal, instead of cropping or padding the image. (note that this is an issue with the resize library, not the NN model itself) Original image (rectangular) / Output (stretched square) HeadshotEx_256px HeadshotEx_generated

MentalGear commented 4 years ago

If you crop your input photo to a square 1:1 ratio before running the NN on it, the result will come out correct. This means, either crop or pad your image to a square to retain the subject's correct ratio.

tushar-31093 commented 1 year ago

return f'ffmpeg -i {inp} -ss {start} -t {time} -filter:v "crop={w}:{h}:{left}:{top}, scale=256:256" crop.mp4'

say that w and h is calculated as 300 and 400 respectively. You are scaling a rectangle are into a square (256, 256).

return f'ffmpeg -i {inp} -ss {start} -t {time} -filter:v "crop={300}:{400}:{left}:{top}, scale=256:256" crop.mp4'

Yep. Just realised this is the issue. Were you able to fix it?