-
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
Feat/inference #82
Feat/inference #82
Conversation
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.
Left a few nit-picky comments, otherwise LGTM! (once the checks pass)
luxonis_train/core/core.py
Outdated
@@ -17,7 +18,7 @@ | |||
from luxonis_ml.nn_archive.config import CONFIG_VERSION | |||
from luxonis_ml.utils import LuxonisFileSystem, reset_logging, setup_logging | |||
from typeguard import typechecked | |||
|
|||
from luxonis_ml.data import LabelType |
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.
Use luxonis_train.enums.TaskType
instead. (see #78)
luxonis_train/core/core.py
Outdated
@@ -419,6 +420,7 @@ def infer( | |||
self, | |||
view: Literal["train", "val", "test"] = "val", | |||
save_dir: str | Path | None = None, | |||
img_path: Optional[str] = None |
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.
Instead of Optional[str]
, you should use str | None
(Optional
is deprecated in python 3.10)
luxonis_train/core/core.py
Outdated
else: | ||
self._process_dataset_images(view, save_dir) | ||
|
||
def _process_single_image(self, img_path: Path, view: str, save_dir: Optional[str | Path]) -> None: |
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.
It might be better to move these methods to luxonis_train.core.utils.infer_utils
luxonis_train/__main__.py
Outdated
@@ -50,6 +50,11 @@ class _ViewType(str, Enum): | |||
typer.Option(help="Where to save the inference results."), | |||
] | |||
|
|||
ImgPathType = Annotated[ | |||
Optional[str], |
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.
str | None
luxonis_train/core/core.py
Outdated
for inputs, labels in self.pytorch_loaders[view]: | ||
images = get_unnormalized_images(self.cfg, inputs) | ||
outputs = self.lightning_module.forward( | ||
inputs, labels, images=images, compute_visualizations=True | ||
) | ||
render_visualizations(outputs.visualizations, save_dir) | ||
|
||
def _prepare_labels(self, view: str, img_shape: tuple) -> tuple: |
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.
_create_dummy_labels
might be a better name
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.
LGTM, left some comments
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.
LGTM
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## dev #82 +/- ##
======================================
Coverage ? 96.21%
======================================
Files ? 139
Lines ? 6148
Branches ? 0
======================================
Hits ? 5915
Misses ? 233
Partials ? 0 ☔ View full report in Codecov by Sentry. |
Inference Functionality Updates
Refactored the
infer()
method with the following helper methods:_process_single_image
: Handles inference for a single image file._process_directory_images
: Handles inference for image files in a directory._process_dataset_images
: Handles inference on dataset images._prepare_labels
: Prepares labels for various tasks.The
infer()
method now supports: