Skip to content

Conversation

@Borda
Copy link
Member

@Borda Borda commented Jan 7, 2026

This pull request refactors the command-line interface (CLI) logic for all three speed estimation example scripts (inference_example.py, ultralytics_example.py, and yolo_nas_example.py) to improve usability and maintainability. The main changes involve replacing the previous argparse-based CLI with a new approach that uses jsonargparse when available, and falls back to parsing positional arguments otherwise. Additionally, the main logic in each script is now encapsulated in a main function with explicit arguments, and argument passing throughout the code is updated for clarity and consistency.

CLI refactoring and usability improvements:

  • Replaced the argparse-based CLI in all three example scripts with logic that tries to use jsonargparse for automatic CLI argument parsing, and falls back to manual positional argument parsing if jsonargparse is not installed. This makes the scripts more flexible and easier to use from the command line. [1] [2] [3] [4] [5] [6]

  • Encapsulated the main script logic in a main function with explicit parameters in each file, improving code readability and enabling easier reuse and testing. [1] [2] [3]

Argument handling and code consistency:

  • Updated all usages of CLI arguments throughout the scripts to reference the new function parameters instead of the previous args object, ensuring consistency and correctness. [1] [2] [3]

  • Improved handling of optional arguments and default values for model configuration, API keys, and thresholds, making it clearer and more robust for users to provide or omit arguments. [1] [2] [3] [4] [5] [6]

Minor import adjustments:

  • Removed unnecessary argparse imports and added sys imports in all three scripts, reflecting the change in argument parsing approach. [1] [2] [3]

Part of #2090

Copilot AI review requested due to automatic review settings January 7, 2026 20:07
@Borda Borda requested a review from SkalskiP as a code owner January 7, 2026 20:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the CLI argument parsing for three speed estimation example scripts, replacing argparse with a hybrid approach that uses jsonargparse when available and falls back to positional argument parsing otherwise. The main logic in each script has been encapsulated into a main() function with explicit parameters for better code organization and reusability.

Key Changes:

  • Introduced a flexible CLI parsing mechanism that tries jsonargparse first and falls back to manual positional argument parsing
  • Encapsulated script logic into main() functions with explicit parameter definitions and docstrings
  • Streamlined detection filtering by passing confidence and IoU thresholds directly to model inference methods instead of post-processing

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.

File Description
examples/speed_estimation/yolo_nas_example.py Refactored CLI parsing, encapsulated main logic, and updated YOLO-NAS model inference to pass thresholds as parameters
examples/speed_estimation/ultralytics_example.py Refactored CLI parsing, encapsulated main logic, and streamlined Ultralytics model inference with threshold parameters
examples/speed_estimation/inference_example.py Refactored CLI parsing, encapsulated main logic with additional Roboflow parameters, and updated inference API calls with thresholds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Borda and others added 3 commits January 7, 2026 21:19
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52%. Comparing base (8df7aea) to head (5f8cc57).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #2056   +/-   ##
=======================================
  Coverage       52%     52%           
=======================================
  Files           61      61           
  Lines         7077    7076    -1     
=======================================
  Hits          3657    3657           
+ Misses        3420    3419    -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda Borda changed the title refactor(speed_estimation): improve CLI argument parsing example(speed_estimation): improve CLI argument parsing Jan 12, 2026
@Borda Borda changed the title example(speed_estimation): improve CLI argument parsing examples/speed_estimation: improve CLI argument parsing Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants