⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
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]

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.

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