opendr-eu / opendr

A modular, open and non-proprietary toolkit for core robotic functionalities by harnessing deep learning
Apache License 2.0
611 stars 94 forks source link

Real time Object detection in agricultural applications #488

Closed ManosMpampis closed 7 months ago

ManosMpampis commented 8 months ago

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

tsampazk commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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

ManosMpampis commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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.

ManosMpampis commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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.

ManosMpampis commented 8 months ago

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.

passalis commented 7 months ago

Thank you!