-
Notifications
You must be signed in to change notification settings - Fork 97
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
Shifted predictions when predicting on videos with different aspect ratio #596
Comments
Ok, we will try workaround and report. |
It is not clear if this remains as an issue, but we should at a minimum add some tests here:
|
Hi, I'm using SLEAP from the source, and I have the problem described above. Do I need to predict again with the solution above or can I just apply it after the analysis? SLEAP is very useful BTW, thanks! Leonardo |
Hi @leonardolv, Thanks for confirming that this remains an issue! We will work on providing a more permanent fix. The Thanks, |
Hi @roomrys, I edited the training_config.json as @talmo suggested but it does not work. Please let me know if you need more info about the bug. Is there any other solution to this shift in predictions? Thanks, Leonardo |
Hi @leonardolv, Can we solicit you for a sample video and model please? Thanks, |
Hi @roomrys, Sorry for the late response. Thanks for your answer. Best, Leonardo |
Update: Bug located - creating PR + testsThe problem was that we had a leftover line in sleap/sleap/nn/data/resizing.py Line 406 in 44e4661
and again for any sleap/sleap/nn/data/resizing.py Line 431 in 44e4661
which results in reversing too large/small of a scale for higher/lower resolution videos hence the instances being too big/small on respective resolutions. Test1 (Crop to different aspect ratio, instance size remains same)
Test2 (Pad to different aspect ratio, instance size remains same)
Test3 (Up-sample keeping same aspect ratio, instances are scaled up)
Test4 (Down-sample keeping aspect ratio, instances are scaled down)
Ideas:
Observations
Relevant Code
|
Hey, any update to this? We are facing the same issue when trained the network with video sizes of 1248x1248 but now predicting on a different video size (1408x1408). We are doing this because we were losing some corners. I also tried to rescale my prediction videos to 1248x1248 using ffmpeg toolbox but the way this scaling is done is still causing some constant offset to all instances (even when predicting a sequence of frames using flow). It would be nice if we don't have to retrain the network. Also any advise on what would happen if we train the same network with images/videos of different sizes? |
Hi @anas-masood, I just ran a quick test: training the network with images/videos of different size still results in offset predictions in the videos where SLEAP tries to automatically rescale the image/video. I have shifted my focus back to this PR and will post updates here. Thanks, |
@roomrys , thanks so much. For now we have trained another network on our desired resolution but reading (superficially) through the doc i found that the tracker and network both crop and resize for data augmentation meaning the network prediction should be robust to this. Must be happening at rescaling (scaling back) the node values to the input image. Don't know if i am totally correct though. Would love to start contributing and testing but have loads on my plate. Bonne chance and let me know if you find a solution. |
Hi @anas-masood, @leonardolv, The fix has been merged into develop and will be available in the next release. Alternatively, you can install SLEAP from source to get the fix now. Thanks, |
This issue has been resolved in the new release - install here. |
It looks like the predictions are slightly off when predicting on videos that have a different aspect ratio than those used for training.
This was supposed to be fixed in v1.1.3 (in #524), but it seems to still be happening in some(?) cases.
Workaround:
Disable this functionality by editing
training_config.json
for each model used for inference and setting:"resize_and_pad_to_target": false
.Related issues: #516, #584
The text was updated successfully, but these errors were encountered: