Skip to content
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

Real time Object detection in agricultural applications #488

Merged
merged 21 commits into from
Nov 29, 2023

Conversation

ManosMpampis
Copy link
Collaborator

This PR aims to enhance the speed capabilities of Nanodet Object detection pipeline.
Add features in inference and training,
Add optimization options for TensorRT,
Ensure JIT script capabilities for embedded devices.
Add a new model nanodet-plus-fast with pretrained weights for object detection crops in RoboWeedMap dataset

@ManosMpampis ManosMpampis changed the title Real time od in agricultural Real time Object detection in agricultural applications Nov 15, 2023
@passalis passalis added the test sources Run style checks label Nov 20, 2023
@ManosMpampis ManosMpampis marked this pull request as ready for review November 20, 2023 15:27
@tsampazk tsampazk added the test tools Test the toolkit methods label Nov 20, 2023
@tsampazk
Copy link
Collaborator

From what i can tell, tests fail due to the new dependency pycuda introduced which fails to install during toolkit installation and subsequently results in an incomplete installation of the env.

At this stage i would suggest to investigate whether it is crucial to include the new dependencies as a first step to fix this. @passalis

@ManosMpampis
Copy link
Collaborator Author

ManosMpampis commented Nov 20, 2023

The thing is, for real time applications in embedded devices it is essential to use TensorRT and must initialize pycude for TensorRT. Is it better to use a try: except: to informe the user to manually install pycuda and TensorRT?

@tsampazk
Copy link
Collaborator

The thing is, for real time applications in embedded devices it is essential to use TensorRT and must initialize pycude for TensorRT. Is it better to use a try: except: to informe the user to manually install pycuda and TensorRT?

Even better, if this is crucial only for embedded devices maybe we can only include it in the installation of the toolkit designed for the embedded devices. I suggest to investigate whether we can have a workaround where these options become available only when running on appropriate devices. @passalis any thoughts?

@passalis
Copy link
Collaborator

passalis commented Nov 21, 2023

Can't we have a standalone script in projects that performs any conversions necessary?

@ManosMpampis
Copy link
Collaborator Author

I think I can manage that but, because it is an important implementation that can be used, I think it would be beneficial to be in the main Learner so it is easier to find from pip installations. The main reason that pycuda it is not installed it is because it can not find the nvcc compiler. Don't we install in during tool installation? I would write a script in projects for now but I think would be better to fix this installation problem.

@passalis
Copy link
Collaborator

We cannot assume that nvcc will be available, since we also support CPU-only installations. The simplest options are either to check if nvcc/pycuda and tensorrt are available in the learner before importing anything related to these or moving the optimization into a separate script. Both sounds ok to me, so we could go with the easiest to implement option.

@passalis
Copy link
Collaborator

If we go with the first one though, it is more complicated to handle the dependencies issues, which is the main issue right now as far as I understand.

fix nanodet_RepVGG_A0_416.yml and nanodet_g.yml,
simplify vgg backbone
transfer tensorRT dependencies into gpu installation
small fixes into prints - docks
@ManosMpampis
Copy link
Collaborator Author

I have tested all tools in my machine with fresh installation as it is noted in: https://github.com/opendr-eu/opendr/blob/master/docs/reference/installation.md#installing-for-gpu

If it passes the Tests in CI I think we can continue with the review

@tsampazk
Copy link
Collaborator

I tested the gpu installation of this branch on a local machine and it works fine. Before moving on with the review, @ManosMpampis there are a lot of changes in the algorithm directory. Are these changes coming from a parent repo or similar, or are they your own modifications?

@ManosMpampis
Copy link
Collaborator Author

Some scripts are from the original repo of Nanodet that the tool was already taken from. autobach.py and torch_utils.py are modified from YoloV5 repo but most of the changes are mine. Do you think that I need to change the licence copyrights?

@tsampazk
Copy link
Collaborator

Some scripts are from the original repo of Nanodet that the tool was already taken from. autobach.py and torch_utils.py are modified from YoloV5 repo but most of the changes are mine. Do you think that I need to change the licence copyrights?

Ok then you can add what relevant information you think is valid here. I was mainly asking this because when we use code from other repositories as-is, we don't review it as part of OpenDR, but since you modified these files, i think we should.

@ManosMpampis
Copy link
Collaborator Author

Thank you for your comments @tsampazk and @passalis. I update the branch with your suggestions, tell me if you think anything else needs to change before we are ready to merge this PR.

@tsampazk tsampazk self-requested a review November 27, 2023 09:00
Copy link
Collaborator

@tsampazk tsampazk left a comment

Choose a reason for hiding this comment

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

Thank you @ManosMpampis for the new features, i've left some comments below.

docs/reference/object-detection-2d-nanodet.md Outdated Show resolved Hide resolved
docs/reference/object-detection-2d-nanodet.md Outdated Show resolved Hide resolved
docs/reference/object-detection-2d-nanodet.md Outdated Show resolved Hide resolved
docs/reference/object-detection-2d-nanodet.md Outdated Show resolved Hide resolved
docs/reference/object-detection-2d-nanodet.md Outdated Show resolved Hide resolved
ManosMpampis and others added 3 commits November 28, 2023 14:42
Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com>
update model heads to have unified initializations and update config_file_detail.md .
delete unused parameter of yml files.
@ManosMpampis
Copy link
Collaborator Author

As I resolve this comment:
https://github.com/opendr-eu/opendr/pull/488/files/348d3cfe6064315ce9b9329820aaf92b25a21bfc#r1406131970 ,
I noticed that, config_file_detail.md in configs do not explain in detail the head parameters and even shows an unused parameter. I update the .md - delete the scales_per_octave parameter from models because it is unused. Last, I change the naming of 2 parameters in gfl_head.py and nanodet_plus_head.py to keep it consistent across all modules. Sorry for the inconvenient.

Copy link
Collaborator

@tsampazk tsampazk left a comment

Choose a reason for hiding this comment

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

Thank you!

@passalis
Copy link
Collaborator

Thank you!

@passalis passalis merged commit 9429785 into develop Nov 29, 2023
48 checks passed
@passalis passalis deleted the Real-Time-OD-In-AGRICULTURAL branch November 29, 2023 09:14
lucamarchionni pushed a commit to lucamarchionni/opendr that referenced this pull request Jun 10, 2024
* add new augmentation strategies

* add VGG backbone

* easier code readability to add custom losses

* better code readability

* better code readability and small bug fixes

* better and more stable training implementation and logging

* add cache in dataset

* add faster post processing in nanodet_plus_head.py and add new nanodet_plus_fast model

* add TensorRT optimizations and fix embedded device inference,
fix optimization procedure and add dynamic and channel last implementations for faster inference

* add TensorRT optimizations and fix embedded device inference,
fix optimization procedure and add dynamic and channel last implementations for faster inference

* update docks and add warning ignores in test_nanodet

* delete unused code,
fix nanodet_RepVGG_A0_416.yml and nanodet_g.yml,
simplify vgg backbone
transfer tensorRT dependencies into gpu installation
small fixes into prints - docks

* fix a bug that still uses gpu nodes even self.device was set to "cpu"

* update tool dock as noted in PR suggestions

* Apply suggestions from code review

Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com>

* update dynamic input explanation accross optimization and inference.
update model heads to have unified initializations and update config_file_detail.md .
delete unused parameter of yml files.

* fix TensorRT loading message and docs as suggested

---------

Co-authored-by: ManosMpampis <gmp.manos@gmail.com>
Co-authored-by: Nikolaos Passalis <passalis@users.noreply.github.com>
Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test sources Run style checks test tools Test the toolkit methods
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants