-
Notifications
You must be signed in to change notification settings - Fork 1
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
Style Transfer Model Returns Wrong Dimensions when a (1920x1080x3) form a full HD webcam is passed through it. #1
base: master
Are you sure you want to change the base?
Conversation
…ransferred would not be return in the correct resolution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @Oleffa this is a good idea. I have a comment so that we can have both behavior with a simple environment variable (or maybe we should go toward command line parameters I'n not sure).
demos/demo_style_transfer.py
Outdated
|
||
resize = False | ||
if frame_style.shape != (720, 1080, 3): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice but I would like to put this condition (and the size of the reshape) as a parameter.
Could you use a system variable like I did with CAMERA that give the webcam number ? than you could call the scipt with :
RESHAPE=1080x720 python demo_style_transfer.py
and not reshape if no sizes are provided?
I tried it on my HD webcam and it gave weird ratios so I don't think it should be fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, some form of parameter would add flexibility. But in this case does it eve make sense to reshape to something else that 1080x720 if the network can only work with that resolution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original script works on my HD webcam (and the low resolution one) with no need for reshape. The reshape parameter is definitely interesting because HD is very slow when no GPU is available though.
Do we really need the out to be exactly the same resolution as the input? it is shown in the different windows no?
It seems to me that it is hard to make OpenCV script work on different hardware ;).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think I understand. I was just fixing the issue of the model returning observations that have a different shape than the input frame.
From what I understand you were talking about adding a feature to pass the desired resolution such that one could choose to resize the input image and obtain a similarly sized output image.
I implemented that function. Running the demo with RESIZE=320x160 for example resizes the webcam image to 320x160x3 and the resulting output image is resized to also fit that resolution. Not passing the RESIZE variable falls back to the default of 1080x720 with no resizing when the webcam input is already in the same resolution. I also added a warning message in case resizing is performed.
As you had mentioned, using smaller input resolutions greatly speeds up the inference.
Let me know if this behaviour is as expected :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's great thank you, yes you understood me very well.
I was thinking that maybe when no RESIZE shape is given we should not do the resize (which you do in the code if the native resolution of the webcam is not the default values 720, 1080).
When using a full HD webcam in the style transfer demo, the program crashes when filling the returned image into frame_style. Frame style is 1920x1080 (same resolution as the webcam image), but the model returns a 1920x1088 image.