Skip to content

Conversation

@SakhinetiPraveena
Copy link
Collaborator

I've refactored the segmentation model classes by introducing a new base class, PerceptionModel, which SegmentationModel now inherits from. All functionalities common to both segmentation and detection models have been moved to PerceptionModel to promote code reuse and maintain a consistent structure across different perception tasks.

@SakhinetiPraveena SakhinetiPraveena marked this pull request as draft April 14, 2025 03:52
@dpascualhe dpascualhe linked an issue Apr 14, 2025 that may be closed by this pull request
@dpascualhe
Copy link
Collaborator

@SakhinetiPraveena Looks good so far 👍
Good job!

@SakhinetiPraveena
Copy link
Collaborator Author

SakhinetiPraveena commented Apr 19, 2025

Hi @dpascualhe

I have defined DetectionModel, ImageDetectionModel and LiDARDetectionModel classes and updated the PR. I have used DetectionDataset class in the code which is yet to be defined, so merging this will raise errors now. Once Dataset classes are ready we can proceed with merging this as well.

And during inference I am using the return type List[dict]. I believe this data type would be useful incase of computations and visualisations.
The sample result would be something like this :

[
  {"class_id": 1, "confidence": 0.91, "bbox": [50.0, 30.0, 200.0, 180.0]},
  {"class_id": 2, "confidence": 0.88, "bbox": [120.5, 85.0, 300.0, 250.0]}
]

To make it more secure, instead of a dict I can define a NamedTuple like shown below and return List[DetectionBox] instead.

class DetectionBox(NamedTuple):
    bbox: list[float]
    confidence: float
    class_id: int
    label: str  # optional

Do let me know if you think that this would be an overkill or any alternative way to return the results.

@SakhinetiPraveena SakhinetiPraveena marked this pull request as ready for review April 19, 2025 10:08
@SakhinetiPraveena SakhinetiPraveena changed the title Refactored Segmentation model class structure Refactored model.py to support image and LiDAR detection models. Apr 19, 2025
@dpascualhe
Copy link
Collaborator

Looking good 👍

It serves as a solid blueprint for adding the required functionality in the future. I'd keep it as a draft for now until the changes in the dataset side are ready. Regarding the return type, I think a list of dicts is reasonable. A named tuple might be good for internal processing but might be harder to handle externally (e.g. if a user wants to dump results to a JSON file directly). Again, good job 😄 .

@SakhinetiPraveena
Copy link
Collaborator Author

Thanks a lot for the feedback @dpascualhe .

So while the other changes are getting ready, I can work on generating pip package and pushing to PyPi. Let me know if you have anything else in mind that I can take up instead.

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.

Refactor model classes to support object detection

3 participants