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

Nanodet C API. Onnx and Libtorch (JIT) modules implementations and Libtorch Installation. #352

Merged
merged 111 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
02a2513
Onnx and Jit tracing-scripting implementation with python and c api i…
Nov 22, 2022
a402954
Implementation of libtorch and torch vision installation as part of t…
Nov 22, 2022
cbf2a9a
add licence and file name corection
Nov 22, 2022
cce417f
style, inconclusive cppcheck fixes.
Nov 23, 2022
c433aeb
Merge branch 'develop' into nanodet_c
ad-daniel Nov 23, 2022
a1a4ac2
Fixes for C API initilization errors
Nov 24, 2022
b15de60
Deleting no used code
Nov 24, 2022
42815d3
macos cppcheck -> C style fixes
Nov 24, 2022
08ed2c1
macos cppcheck -c style fixes
Nov 24, 2022
75deceb
c-style pointer delceration fixes
Nov 24, 2022
0d4b1be
c-style pointer delceration fixes
Nov 24, 2022
477f842
cpp casting casting fixes
Nov 24, 2022
f1fed96
bug fixes
Nov 24, 2022
9aad554
Merge branch 'develop' into nanodet_c
ad-daniel Nov 24, 2022
e26e265
Update projects/python/perception/object_detection_2d/nanodet/export_…
ManosMpampis Nov 25, 2022
8fbf436
Update install_torch_c_api.sh
ManosMpampis Nov 25, 2022
882d0a1
Update dependencies/install_torch_c_api.sh
ManosMpampis Nov 25, 2022
e3e1eea
Update include/nanodet_c.h
ManosMpampis Nov 25, 2022
83bdfbd
Update include/nanodet_c.h
ManosMpampis Nov 25, 2022
c7376e2
Update include/nanodet_c.h
ManosMpampis Nov 25, 2022
fb4e6b6
Update include/nanodet_c.h
ManosMpampis Nov 25, 2022
8f7fb24
Update include/opendr_utils.h
ManosMpampis Nov 25, 2022
61412b3
Update include/target.h
ManosMpampis Nov 25, 2022
16e61c2
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
f9a0bf4
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
2bca053
Update nanodet.md
ManosMpampis Nov 25, 2022
8549689
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
730d192
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
ef23d94
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
c41d578
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
96e4c0e
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
bda772f
Update nanodet.md
ManosMpampis Nov 25, 2022
0feb2f2
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
96978ce
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
e242b78
Update Makefile
ManosMpampis Nov 25, 2022
51f4684
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
a9537ec
Update docs/reference/nanodet.md
ManosMpampis Nov 25, 2022
5589966
Update nanodet.md
ManosMpampis Nov 25, 2022
e3f6616
Update projects/c_api/Makefile
ManosMpampis Nov 25, 2022
aca73a2
Update projects/python/perception/object_detection_2d/nanodet/README.md
ManosMpampis Nov 25, 2022
bf61b2c
Update eval_demo.py
ManosMpampis Nov 25, 2022
5f0c364
Update projects/python/perception/object_detection_2d/nanodet/export_…
ManosMpampis Nov 25, 2022
9128f7d
Update projects/python/perception/object_detection_2d/nanodet/README.md
ManosMpampis Nov 25, 2022
3631fc4
Update projects/python/perception/object_detection_2d/nanodet/README.md
ManosMpampis Nov 25, 2022
f06f58a
Merge branch 'develop' into nanodet_c
ad-daniel Nov 25, 2022
5c1e458
installing libtorch and vision with respect to CUDA of the user
Nov 28, 2022
c547fc2
better explanations of variables in optimization runtimes
Nov 28, 2022
3d3a3a6
small typing fixes
Nov 28, 2022
5fb0755
Merge branch 'develop' into nanodet_c
ManosMpampis Nov 30, 2022
b8c543c
Merge branch 'develop' into nanodet_c
ad-daniel Dec 6, 2022
4006735
Merge branch 'develop' into nanodet_c
ad-daniel Dec 6, 2022
704952f
Fix dependency
ad-daniel Dec 6, 2022
624deec
Merge branch 'develop' into nanodet_c
ManosMpampis Dec 8, 2022
ed2a13b
Merge branch 'develop' into nanodet_c
passalis Dec 8, 2022
e649c60
Update dependencies.ini
ManosMpampis Dec 9, 2022
467c1f1
update docs for new data structures and utilities of c api
Dec 12, 2022
617572d
new source, samples, utilities and test for onnx C API. The new scrip…
Dec 12, 2022
fcd4f9c
bug fixes in onnx exporting.
Dec 12, 2022
b09575b
Merge branch 'develop' into nanodet_c
ManosMpampis Dec 12, 2022
eaa9a0d
Revert "update docs for new data structures and utilities of c api"
Dec 13, 2022
953a193
Revert "bug fixes in onnx exporting."
Dec 13, 2022
bd6fb6d
Revert "Revert "bug fixes in onnx exporting.""
Dec 13, 2022
83df919
Revert "new source, samples, utilities and test for onnx C API. The n…
Dec 13, 2022
70d7543
Revert "bug fixes in onnx exporting."
Dec 13, 2022
67c78df
revert last commits, change files for cpp styles as wiki says and bet…
Dec 13, 2022
11d78d8
Merge branch 'nanodet_c' of https://github.com/opendr-eu/opendr into …
Dec 13, 2022
9a6baf0
change function name to be uniform with the others
Dec 14, 2022
13d23f9
doc for c nanodet
Dec 14, 2022
a0dbac9
Added small Json parser and installation script for easier navigation…
Dec 15, 2022
62c0266
Update projects/c_api/README.md
ManosMpampis Dec 16, 2022
8f01093
Update dependencies/install_torch_c_api.sh
ManosMpampis Dec 16, 2022
d7e6c86
Update dependencies/install_torch_c_api.sh
ManosMpampis Dec 16, 2022
9ff5c63
Update install_torch_c_api.sh
ManosMpampis Dec 16, 2022
c398d75
Update download_torch.py
ManosMpampis Dec 16, 2022
42fc691
Merge branch 'develop' into nanodet_c
ad-daniel Dec 19, 2022
30c205a
Merge branch 'develop' into nanodet_c
passalis Dec 21, 2022
ba8aa8c
Merge branch 'develop' into nanodet_c
ManosMpampis Dec 21, 2022
fbd3906
Merge branch 'develop' into nanodet_c
ad-daniel Dec 21, 2022
d320fba
Update utilities.py
ManosMpampis Dec 21, 2022
39d4c20
Fixes
ad-daniel Dec 22, 2022
5a95f14
Merge branch 'develop' into nanodet_c
ad-daniel Dec 22, 2022
3b24ab3
Fixes of suggestions
Dec 23, 2022
fb0c4fe
Fixes of suggestions
Dec 23, 2022
a191380
Fixes of suggestions
Dec 23, 2022
ad741a1
Fixes of suggestions
Dec 23, 2022
d0c0eaa
Merge branch 'develop' into nanodet_c
ManosMpampis Dec 27, 2022
f47fc17
added json parser in utilities
Dec 29, 2022
76ecd07
unnecessary use of filesystem, easier implementation in embeded
Dec 29, 2022
ebbc6d9
Merge branch 'nanodet_c' of https://github.com/opendr-eu/opendr into …
Dec 29, 2022
5f8d84e
default directory for saves change to `temp`
Jan 5, 2023
64c466f
change to warnings errors and exceptions
Jan 5, 2023
1df22cc
Transfer warnings for jit and ort simultaneously loaded from _load to…
Jan 5, 2023
2e37c40
Change naming style. All .cpp files have only CPP style naming and .c…
Jan 5, 2023
57c5903
Merge branch 'develop' of https://github.com/opendr-eu/opendr into na…
Jan 5, 2023
fdd0233
Merge branch 'develop' into nanodet_c
tsampazk Jan 6, 2023
cbb23c5
license test update
Jan 9, 2023
a7ac402
Merge branch 'develop' of https://github.com/opendr-eu/opendr into na…
Jan 9, 2023
d25a785
Merge branch 'develop' into nanodet_c
ManosMpampis Jan 9, 2023
9b87386
Merge branch 'nanodet_c' of https://github.com/opendr-eu/opendr into …
Jan 9, 2023
53a58c3
Apply suggestions from code review
ManosMpampis Jan 15, 2023
7c84d59
Apply suggestions from code review
Jan 15, 2023
cd34879
Merge branch 'nanodet_c' of https://github.com/opendr-eu/opendr into …
Jan 15, 2023
bca8c37
fixe bug to find cuda
Jan 19, 2023
4cae0ae
add automatic random colors
Jan 19, 2023
d2777a4
better implementation of optimize
Jan 19, 2023
bda2e22
add XMLBaseDataset option
Jan 19, 2023
d091dbb
train bug fix
Jan 19, 2023
6acf11d
train bug fix
Jan 19, 2023
96c86a7
tipo fix
Jan 19, 2023
42ddb48
add changes and some better namings
Jan 19, 2023
3aaffb2
Merge branch 'develop' into nanodet_c
tsampazk Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ install_compilation_dependencies:
@+echo "#"; echo "# * Install Compilation Dependencies *"; echo "#"
@+cd dependencies; ./install.sh compilation
@+cd dependencies; ./install_onnx.sh
@+cd dependencies; ./install_rapidjson.sh
@+cd dependencies; ./install_torch_c_api.sh
@+make --silent -C src/opendr/control/mobile_manipulation $(TARGET) OPENDR_HOME="$(OPENDR_HOME)";
@+make --silent -C src/opendr/control/single_demo_grasp $(TARGET) OPENDR_HOME="$(OPENDR_HOME)";

Expand Down
125 changes: 125 additions & 0 deletions dependencies/download_torch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Copyright 2020-2022 OpenDR European Project
ManosMpampis marked this conversation as resolved.
Show resolved Hide resolved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import argparse
import glob
from urllib.request import urlretrieve
import os
import warnings


def search_on_path(filenames):
for p in os.environ.get('PATH', '').split(os.pathsep):
for filename in filenames:
full = os.path.join(p, filename)
if os.path.exists(full):
return os.path.abspath(full)
return None


def get_cuda_path():
nvcc_path = search_on_path(('nvcc', 'nvcc.exe'))
if nvcc_path is not None:
cuda_path_default = os.path.normpath(os.path.join(os.path.dirname(nvcc_path), '..'))
_cuda_path = cuda_path_default
elif os.path.exists('/usr/local/cuda'):
_cuda_path = '/usr/local/cuda'
else:
_cuda_path = None

return _cuda_path


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--cuda_path", help="Path to installed cuda", type=str, default=None)
parser.add_argument("--opendr_device", help="Target device for installation",
type=str, choices=["gpu", "cpu"], default="gpu")
parser.add_argument("--torch_version", help="Specifies LibTorch version to be installed", type=str, default="1.9.0")
args = parser.parse_args()

COMPATIBILITY_VERSIONS = {
"1.13.1": "0.14.1",
"1.13.0": "0.14.0",
"1.12.0": "0.13.0",
"1.11.0": "0.12.0",
"1.10.2": "0.11.3",
"1.10.1": "0.11.2",
"1.10.0": "0.11.1",
"1.9.1": "0.10.1",
"1.9.0": "0.10.0",
}

warnings.simplefilter("error")

TORCH_VERSION = args.torch_version
VISION_VERSION = COMPATIBILITY_VERSIONS[TORCH_VERSION]

CUDA_VERSION = None
DEVICE = None
# Find Device
if args.opendr_device == "gpu":
try:
if args.cuda_path is None:
CUDA_PATH = get_cuda_path()
else:
CUDA_PATH = args.cuda_path
version_file_type = glob.glob(f"{CUDA_PATH}/version*")
if version_file_type[0].endswith('.txt'):
version_file = open(f"{CUDA_PATH}/version.txt", mode='r')
version_line = version_file.readlines()
version_line = version_line[0].replace(".", "")
CUDA_VERSION = version_line[13:16]
elif version_file_type[0].endswith('.json'):
version_file = open(f"{CUDA_PATH}/version.json", mode='r')
version_dict = json.load(version_file)
CUDA_VERSION = version_dict["cuda"]["version"]
CUDA_VERSION = CUDA_VERSION.replace(".", "")
CUDA_VERSION = CUDA_VERSION[:3]
else:
warnings.warn("\033[93m No CUDA version file found.")
DEVICE = f"cu{CUDA_VERSION}"
except:
warnings.warn("\033[93m No CUDA installation found.\n"
"Please install CUDA or specify CUDA path with export CUDA_PATH=/path/to/your/cuda.")
exit()
else:
DEVICE = "cpu"

# Download Libtorch
try:
file_url_libtorch = f"https://download.pytorch.org/libtorch/{DEVICE}/" \
f"libtorch-cxx11-abi-shared-with-deps-{TORCH_VERSION}%2B{DEVICE}.zip"

DOWNLOAD_DIRECTORY = "libtorch.zip"

urlretrieve(file_url_libtorch, DOWNLOAD_DIRECTORY)

except:
warnings.warn("\033[93m No LibTorch found for your specific device and torch version.\n"
"Please choose another version of torch or install a different version of CUDA.\n"
"Please refer to https://download.pytorch.org/whl/torch_stable.html")
exit()
# Download Vision
try:
file_url_vision = f"https://github.com/pytorch/vision/archive/refs/tags/" \
f"v{VISION_VERSION}.tar.gz"
DOWNLOAD_DIRECTORY = "vision.tar.gz"
urlretrieve(file_url_vision, DOWNLOAD_DIRECTORY)
except:
warnings.warn("\033[93m No torchvision found for your specific torch version.\n"
"Please refer to https://github.com/pytorch/vision for more information.")
exit()

17 changes: 17 additions & 0 deletions dependencies/install_rapidjson.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

if [ ! -d /usr/local/include/rapidjson ]; then

VERSION="1.1.0"

wget https://github.com/Tencent/rapidjson/archive/refs/tags/v${VERSION}.tar.gz --quiet
tar zxf v${VERSION}.tar.gz
cd rapidjson-${VERSION}
sudo mkdir -p /usr/local/include/rapidjson
sudo mv include/rapidjson/* /usr/local/include/rapidjson
cd ..
rm -rf rapidjson-${VERSION}
rm -rf v${VERSION}.tar.gz


fi
64 changes: 64 additions & 0 deletions dependencies/install_torch_c_api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

if [[ -z "$TORCH_VERSION" ]];
then
echo "Torch version not defined, version 1.9.0 will be installed."
echo "For a specific Torch version please define TORCH_VERSION with 'export TORCH_VERSION=x.x.x'"
TORCH_VERSION="1.9.0"
fi

if [ ! -f /usr/local/lib/libtorchvision.so ]; then
TORCH_DIRECTORY="/usr/local/libtorch"

if [[ "$OPENDR_DEVICE" == "gpu" ]]
then
echo "Downloading and installing LibTorch and torchvision (gpu support) ..."
GPU="on"
DEVICE="cu"${CUDA_VERSION}
CUDA_COMPILER="/usr/local/cuda/bin/nvcc"
else
echo "Downloading and installing LibTorch and torchvision (cpu-only) ..."
GPU="off"
DEVICE="cpu"
fi

# Find CUDA version and download torch and vision
echo "Downloading LibTorch and torchvision ..."
# Make sure that we can download files
if [[ -z "$CUDA_PATH" ]];
then
python3 ./download_torch.py --opendr_device "$OPENDR_DEVICE" --torch_version "$TORCH_VERSION"
else
python3 ./download_torch.py --opendr_device "$OPENDR_DEVICE" --torch_version "$TORCH_VERSION" --cuda_path "$CUDA_PATH"
fi
echo "Downloading Libtorch and torchvision done."

# TORCH INSTALLATION
unzip -qq libtorch.zip
cd libtorch

sudo mkdir -p ${TORCH_DIRECTORY}
sudo cp -r ./* ${TORCH_DIRECTORY}
cd ..

# TORCH VISION INSTALLATION
tar zxf vision.tar.gz
mv vision-* vision
cd vision
sudo mkdir -p build
cd build
sudo cmake .. -DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} -DCMAKE_PREFIX_PATH=${TORCH_DIRECTORY} -DWITH_CUDA=${GPU}
sudo make
sudo make install
cd ../..

# CLEAN
sudo rm -rf libtorch
sudo rm -rf libtorch.zip

sudo rm -rf vision
sudo rm -rf vision.tar.gz

sudo ldconfig

fi
12 changes: 6 additions & 6 deletions docs/reference/c-data-h.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@

The *data.h* header provides definitions of OpenDR data types that can be used in the C API of OpenDR.

### struct *opendr_image_t*
### struct *OpendrImageT*
```C
struct opendr_image {
struct OpendrImage {
void *data;
};
typedef struct opendr_image opendr_image_t;
typedef struct OpendrImage OpendrImageT;
```


The *opendr_image_t* structure provides a data structure for storing OpenDR images.
The *OpendrImageT* structure provides a data structure for storing OpenDR images.
Every function in the C API receiving images is expected to use this structure.
Helper functions that directly convert images into this format are provided in *opendr_utils.h*.

The *opendr_image_t* structure has the following field:
The *OpendrImageT* structure has the following field:

#### `void *data` field

A pointer where image data are stored.
*opendr_image_t* is using internally OpenCV images (*cv::Mat*) for storing images.
*OpendrImageT* is using internally OpenCV images (*cv::Mat*) for storing images.
Therefore, only a pointer to the memory location of the corresponding *cv::Mat* is stored.
Please note that the user is not expected to directly manipulate these data without first converting them into OpenCV data type or using the corresponding functions provided in *opendr_utils.h*.
42 changes: 21 additions & 21 deletions docs/reference/c-face-recognition-h.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,62 @@

The *face_recognition.h* header provides function definitions that can be used for accessing the OpenDR face recognition tool.

### Struct *face_recognition_model_t*
### Struct *FaceRecognitionModelT*
```C

struct face_recognition_model {
struct FaceRecognitionModel {
...
};
typedef struct face_recognition_model face_recognition_model_t;
typedef struct FaceRecognitionModel FaceRecognitionModelT;
```
The *face_recognition_model_t* structure keeps all the neccesary information that are required by the OpenDR face recognition tool (e.g., model weights, normalization information, database for person recognition, ONNX session information, etc.).
The *FaceRecognitionModelT* structure keeps all the necessary information that are required by the OpenDR face recognition tool (e.g., model weights, normalization information, database for person recognition, ONNX session information, etc.).


### Function *load_face_recognition_model()*
### Function *loadFaceRecognitionModel()*
```C
void load_face_recognition_model(const char *model_path, face_recognition_model_t *model);
void loadFaceRecognitionModel(const char *modelPath, FaceRecognitionModelT *model);
```
Loads a face recognition model saved in the local filesystem (*model path*) in OpenDR format.
Loads a face recognition model saved in the local filesystem (*modelPath*) in OpenDR format.
This function also initializes a CPU-based ONNX session for performing inference using this model.
The pre-trained models should follow the OpenDR conventions.
The Python API can be used to train and export an optimized OpenDR model that can be used for inference using the C API.

### Function *free_face_recognition_model()*
### Function *freeFaceRecognitionModel()*
```C
void free_face_recognition_model(face_recognition_model_t *model);
void freeFaceRecognitionModel(FaceRecognitionModelT *model);
```
Releases the memory allocated for a face recognition model (*model*).


### Function *infer_face_recognition()*
### Function *inferFaceRecognition()*
```C
opendr_category_target_t infer_face_recognition(face_recognition_model_t *model, opendr_image_t *image);
OpendrCategoryTargetT inferFaceRecognition(FaceRecognitionModelT *model, OpendrImageT *image);
```
This function perform inference using a face recognition model (*model*) and an input image (*image*).
The function returns an OpenDR category structure with the inference results.


### Function *decode_category_face_recognition()*
### Function *decodeCategoryFaceRecognition()*
```C
void decode_category_face_recognition(face_recognition_model_t *model, opendr_category_target_t category, char *person_name);
void decodeCategoryFaceRecognition(FaceRecognitionModelT *model, OpendrCategoryTargetT category, char *personName);
```
Returns the name of a recognized person by decoding the category id into a string (this function uses the information from the built person database).


### Function *build_database_face_recognition()*
### Function *buildDatabaseFaceRecognition()*
```C
void build_database_face_recognition(const char *database_folder, const char *output_path, face_recognition_model_t *model);
void buildDatabaseFaceRecognition(const char *databaseFolder, const char *outputPath, faceRecognitionModelT *model);
```
Build a face recognition database (containing images for persons to be recognized).
This function expects the *database_folder* to have the same format as the main Python toolkit.
The function calculates the features of the person that are contained in the database and it stores it into a binary file that can be then loaded to perform inference (*output_path*).
A loaded face recongition model should be provided (*model*), since this model will be used for the feature extraction process.
This function expects the (*databaseFolder*) to have the same format as the main Python toolkit.
The function calculates the features of the person that are contained in the database and it stores it into a binary file that can be then loaded to perform inference (*outputPath*).
A loaded face recognition model should be provided (*model*), since this model will be used for the feature extraction process.

### Function *load_database_face_recognition()*
### Function *loadDatabaseFaceRecognition()*
```C
void load_database_face_recognition(const char *database_path, face_recognition_model_t *model);
void loadDatabaseFaceRecognition(const char *databasePath, FaceRecognitionModelT *model);

```
Loads an already built database (*database_path) into a face recognition model (*model*).
Loads an already built database (*databasePath*) into a face recognition model (*model*).
After this step, the model can be used for performing inference.

47 changes: 47 additions & 0 deletions docs/reference/c-object-detection-2d-nanodet-jit-h.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## C_API: object_detection_2d_nanodet_jit.h


The *object_detection_2d_nanodet_jit.h* header provides function definitions that can be used for accessing the OpenDR object detection 2D Nanodet tool.

### Struct *NanodetModelT*
```C

struct NanodetModel {
...
};
typedef struct NanodetModel NanodetModelT;
```
The *NanodetModelT* structure keeps all the necessary information that are required by the OpenDR object detection 2D Nanodet tool (e.g., model weights, normalization information, etc.).


### Function *loadNanodetModel()*
```C
void loadNanodetModel(char *modelPath, char *device, int height, int width, float scoreThreshold, NanodetModelT *model);
```
Loads a Nanodet object detection model saved in the local filesystem (*modelPath*) in OpenDR format.
This function also initializes a (*device*) JIT network for performing inference using this model.
The pre-trained models should follow the OpenDR conventions.
The Python API can be used to train and export an optimized OpenDR model that can be used for inference using the C API.

### Function *freeNanodetModel()*
```C
void freeNanodetModel(NanodetModelT *model);
```
Releases the memory allocated for an object detection 2D Nanodet model (*model*).


### Function *inferNanodet()*
```C
OpendrDetectionVectorTargetT inferNanodet(NanodetModelT *model, OpendrImageT *image);
```
This function performs inference using an object detection 2D Nanodet model (*model*) and an input image (*image*).
The function returns an OpenDR detection vector structure with the inference results.


### Function *drawBboxes()*
```C
void drawBboxes(OpendrImageT *image, NanodetModelT *model, OpendrDetectionVectorTargetT *detectionsVector);
```
This function draws the given detections (*detectionsVector*) onto the input image (*image*) and then shows the image on screen.
The (*model*) keeps all the necessary information.

Loading