WongKinYiu / YOLO

An MIT rewrite of YOLOv9
MIT License
492 stars 52 forks source link

Test failing due to incorrect data directory being set #60

Open tloki opened 1 month ago

tloki commented 1 month ago

test test_tools/test_data_loader.py::test_file_stream_data_loader_frame

is failing due to inference_cfg fixture's attribute task.data.source is being set as demo/images/inference/image.png - during test runtime this is being evaluated as path <repo_parent_dir>/YOLO/tests/demo/images/inference/image.png (which does not exist).

There's multiple ways to fix this, to me it was easiest (but I don't know if it was the most elegant) to set fixture inference_cfg to override a path too like:

return get_cfg(overrides=["task=inference", "task.data.source='../demo/images/inference/image.png'"])

let me know if you're up for me to make a pull request to fix it - you can also suggest on how'd you like to fix this and I am willing to contribute

henrytsui000 commented 1 month ago

Hi,

Thank you for your issue. I will run the tests using pytest from the project root instead of directly under the tests directory. I tried running

pytest ./tests/test_tools/test_data_loader.py

on the current main branch head, and it seems there were no test failures. Thanks for your advice.

By the way, I'm considering the test for test_directory_stream_data_loader_frame because I want to ensure the stream data loader correctly loads data from a directory. However, the test may fail due to the order of files, as seen here: GitHub Actions Run.

To address this, I've changed the specific shape test to check if origin_frame.size != (640, 640):

https://github.com/WongKinYiu/YOLO/blob/fb4930bcb6b6357a26391669c1e41872045d7025/tests/test_tools/test_data_loader.py#L64-L69

If you have an elegant solution for this, it would be greatly appreciated!

Best regards,
Henry Tsui