docs: Update README and compilation guides for clarity and consistency, including path corrections and improved formatting. Add copyright notices to source files and adjust file permissions for several scripts and directories.

This commit is contained in:
dian.yuan 2026-02-28 11:06:26 +08:00
parent f960c5030d
commit bd891a96dd
136 changed files with 14413 additions and 9399 deletions

View file

@ -1,170 +1,170 @@
# yolov11
## 1.Overview
YOLOv11 was released by Ultralytics on October 2, 2024. It introduces significant architectural refinements and efficiency optimizations, delivering superior accuracy-speed trade-offs compared to previous generations. With enhanced feature extraction capabilities, YOLOv11 is designed for high-performance real-time applications—including object detection, instance segmentation, and pose estimation—to handle demanding tasks in a wide range of applications.
## 2.Model Download
- **Open Source model**
- **Open Source projects:** https://github.com/ultralytics/ultralytics/tree/v8.3.0
- **Export Model Step:**
- **Install ultralytics**
pip install torch==2.4.1
pip install torchvision==0.19.1
pip install ultralytics==8.3.0
- **Download weights**
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m.pt
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s.pt
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt
- **Export Model**
```
from ultralytics import YOLO
model = YOLO("yolo11n.pt")
model.export(format="onnx", opset=12, simplify=True, dynamic=False, imgsz=640)
```
- **Exported Model**
link to amlogic server( **onnx model or quantized tflite**)
## 3. Model Conversion
```
cd model
Usage: ./adla_covnert.sh model_path adla_tookkit_path target_platform
example
./adla_covnert.sh yolov11m.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
./adla_covnert.sh yolov11s.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
./adla_covnert.sh yolov11n.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
```
| Parameter | Discription |
| ----------------- | ------------------------------------------------------------ |
| model_path | onnx model path |
| adla_tookkit_path | path to adla_toolkit |
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003. for S905X5: PRODUCT_PID0XA005 |
## 4. Demo Run
### CPP
#### 1. Compile
**Prerequisites:**
- Android NDK (r25e recommended)
- `ANDROID_NDK_PATH` environment variable set
**Build:**
```bash
# Build for arm64-v8a
cd examples/yolov11/cpp
AMLNN_HOME=/path/to/amlnn-toolkit ./build-android.sh -a arm64-v8a
```
The executable will be generated at `build/android/yolo11_demo` (Note: executable name may vary, verify in build folder).
#### 2. Run
```bash
# Push executable to device
adb push build/android/yolo11_demo /data/local/tmp/
adb push model/yolov11n_int8_A311D2.adla /data/local/tmp/
adb push imgs /data/local/tmp/
# Run on device
adb shell
cd /data/local/tmp
chmod +x yolo11_demo
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
# Usage: ./yolo11_demo <model_path> <image_dir>
./yolo11_demo yolov11n_int8_A311D2.adla ./imgs
```
**Note:** Replace `yolov11n_int8_A311D2.adla` with your actual model file path.
### Python
**Prerequisites:**
- Python 3.10
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
**Install dependencies:**
```bash
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
```
**Run on device:**
```bash
python yolov11.py \
--model-path ./yolov11n_int8_A311D2.adla \
--image-dir ./imgs \
--run-cycles 1 \
--loglevel INFO
```
Argument Descriptions:
| Argument | Description |
| ----------------- | ------------------------------------------------------------ |
| --board-work-path | Work path on board, default is /data/local/tmp |
| --model-path | path to .adla model |
| --image-dir | Directory containing test images |
| --run-cycles | Number of inference cycles, default is 1 |
| --loglevel | Logging level: DEBUG / INFO / WARNING / ERROR, default is WARNING |
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
## 5.Results
**Performance Feedback**
By setting the loglevel to INFO, the program provides real-time performance metrics upon completion. The console log will display essential hardware and execution details, including:
- Hardware Information: System and ADLA library versions.
- Model Overview: Basic input/output configurations.
- NPU Metrics: Total inference time (latency) and total DRAM bandwidth consumption.
**Detection Output**
The program will print the detection count. The result image with bounding boxes will be saved to the specified output path (`{model_name}_result`).
You can pull the result folder back to view it:
```bash
adb pull /data/local/tmp/yolov11n_int8_A311D2_result
```
![alt text](result.jpg)
**Profiling Visualization**
After a successful run of the Python demo, a folder named after the model (e.g., `{model_name}`) will be generated in the script directory. This folder contains 5 HTML files that provide a visual and detailed breakdown of per-layer performance:
- `hard_op_chart.html` & `soft_op_chart.html`: Hardware/Software op execution details.
- `dram_rd_chart.html` & `dram_wr_chart.html`: Bandwidth read/write distribution.
- `pie_charts_distribution.html`: Overall resource allocation.
You can pull the result folder back to view it:
```bash
adb pull /data/local/tmp/yolov11n_int8_A311D2
```
Taking hard_op_chart.html as an example (shown below), each layer's ADLA operator name includes parentheses containing the index of the corresponding quantized .tflite layer(s); by default, these indices are suppressed, and operators are labeled generically as "hardware" or "software" without numerical suffixes.
# yolov11
## 1.Overview
YOLOv11 was released by Ultralytics on October 2, 2024. It introduces significant architectural refinements and efficiency optimizations, delivering superior accuracy-speed trade-offs compared to previous generations. With enhanced feature extraction capabilities, YOLOv11 is designed for high-performance real-time applications—including object detection, instance segmentation, and pose estimation—to handle demanding tasks in a wide range of applications.
## 2.Model Download
- **Open Source model**
- **Open Source projects:** https://github.com/ultralytics/ultralytics/tree/v8.3.0
- **Export Model Step:**
- **Install ultralytics**
pip install torch==2.4.1
pip install torchvision==0.19.1
pip install ultralytics==8.3.0
- **Download weights**
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11m.pt
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11s.pt
wget https://github.com/ultralytics/assets/releases/download/v8.3.0/yolo11n.pt
- **Export Model**
```
from ultralytics import YOLO
model = YOLO("yolo11n.pt")
model.export(format="onnx", opset=12, simplify=True, dynamic=False, imgsz=640)
```
- **Exported Model**
link to amlogic server( **onnx model or quantized tflite**)
## 3. Model Conversion
```
cd model
Usage: ./adla_convert.sh model_path adla_toolkit_path target_platform
example
./adla_convert.sh yolov11m.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
./adla_convert.sh yolov11s.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
./adla_convert.sh yolov11n.onnx /xxxx/adla-toolkit-binary-3.2.9.3 PRODUCT_PID0XA005
```
| Parameter | Description |
| ----------------- | ------------------------------------------------------------ |
| model_path | onnx model path |
| adla_toolkit_path | path to adla_toolkit |
| target_platform | Specify target platform. for A311D2 : PRODUCT_PID0XA003. for S905X5: PRODUCT_PID0XA005 |
## 4. Demo Run
### CPP
#### 1. Compile
**Prerequisites:**
- Android NDK (r25e recommended)
- `ANDROID_NDK_PATH` environment variable set
**Build:**
```bash
# Build for arm64-v8a
cd examples/yolov11/cpp
AMLNN_HOME=/path/to/amlnn-toolkit ./build-android.sh -a arm64-v8a
```
The executable will be generated at `build/android/yolo11_demo` (Note: executable name may vary, verify in build folder).
#### 2. Run
```bash
# Push executable to device
adb push build/android/yolo11_demo /data/local/tmp/
adb push model/yolov11n_int8_A311D2.adla /data/local/tmp/
adb push imgs /data/local/tmp/
# Run on device
adb shell
cd /data/local/tmp
chmod +x yolo11_demo
export LD_LIBRARY_PATH=/vendor/lib64 or (/vendor/lib)
# Usage: ./yolo11_demo <model_path> <image_dir>
./yolo11_demo yolov11n_int8_A311D2.adla ./imgs
```
**Note:** Replace `yolov11n_int8_A311D2.adla` with your actual model file path.
### Python
**Prerequisites:**
- Python 3.10
- Required packages: `numpy`, `opencv-python`, `amlnnlite`
**Install dependencies:**
```bash
pip install numpy opencv-python amlnnlite-1.0.0-cp310-cp310-linux_aarch64.whl
```
**Run on device:**
```bash
python yolov11.py \
--model-path ./yolov11n_int8_A311D2.adla \
--image-dir ./imgs \
--run-cycles 1 \
--loglevel INFO
```
Argument Descriptions:
| Argument | Description |
| ----------------- | ------------------------------------------------------------ |
| --board-work-path | Work path on board, default is /data/local/tmp |
| --model-path | path to .adla model |
| --image-dir | Directory containing test images |
| --run-cycles | Number of inference cycles, default is 1 |
| --loglevel | Logging level: DEBUG / INFO / WARNING / ERROR, default is WARNING |
The script will automatically process all image files (`.jpg`, `.jpeg`, `.png`, `.bmp`) in the current directory and save results to a `{model_name}_result` folder.
## 5.Results
**Performance Feedback**
By setting the loglevel to INFO, the program provides real-time performance metrics upon completion. The console log will display essential hardware and execution details, including:
- Hardware Information: System and ADLA library versions.
- Model Overview: Basic input/output configurations.
- NPU Metrics: Total inference time (latency) and total DRAM bandwidth consumption.
**Detection Output**
The program will print the detection count. The result image with bounding boxes will be saved to the specified output path (`{model_name}_result`).
You can pull the result folder back to view it:
```bash
adb pull /data/local/tmp/yolov11n_int8_A311D2_result
```
![alt text](result.jpg)
**Profiling Visualization**
After a successful run of the Python demo, a folder named after the model (e.g., `{model_name}`) will be generated in the script directory. This folder contains 5 HTML files that provide a visual and detailed breakdown of per-layer performance:
- `hard_op_chart.html` & `soft_op_chart.html`: Hardware/Software op execution details.
- `dram_rd_chart.html` & `dram_wr_chart.html`: Bandwidth read/write distribution.
- `pie_charts_distribution.html`: Overall resource allocation.
You can pull the result folder back to view it:
```bash
adb pull /data/local/tmp/yolov11n_int8_A311D2
```
Taking hard_op_chart.html as an example (shown below), each layer's ADLA operator name includes parentheses containing the index of the corresponding quantized .tflite layer(s); by default, these indices are suppressed, and operators are labeled generically as "hardware" or "software" without numerical suffixes.
![alt text](Visualization.png)

View file

@ -1,35 +1,35 @@
cmake_minimum_required(VERSION 3.10...3.27)
project(yolo11_demo)
set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
find_package(AMLNN REQUIRED)
include_directories(${AMLNN_INCLUDE_DIR})
link_directories(${AMLNN_LIBRARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
# Set dependency path
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
# Android needs log
link_libraries(log)
endif()
# Find OpenCV
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(yolo11_demo
main.cpp
postprocess.cpp
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
)
target_link_libraries(yolo11_demo
${OpenCV_LIBS}
${AMLNN_LIBRARY}
cmake_minimum_required(VERSION 3.10...3.27)
project(yolo11_demo)
set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../../cmake")
find_package(AMLNN REQUIRED)
include_directories(${AMLNN_INCLUDE_DIR})
link_directories(${AMLNN_LIBRARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/../../../../common)
# Set dependency path
set(3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../../../../dependency")
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
# Android needs log
link_libraries(log)
endif()
# Find OpenCV
message(STATUS "OpenCV_DIR: ${OpenCV_DIR}")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(yolo11_demo
main.cpp
postprocess.cpp
${CMAKE_SOURCE_DIR}/../../../../common/model_loader.cpp
)
target_link_libraries(yolo11_demo
${OpenCV_LIBS}
${AMLNN_LIBRARY}
)

View file

@ -58,9 +58,9 @@ int main(int argc, char** argv) {
int nw = img.cols * scale, nh = img.rows * scale;
int px = (kInputW - nw) / 2, py = (kInputH - nh) / 2;
cv::Mat res, canvas = cv::Mat::zeros(kInputH, kInputW, CV_32FC3);
canvas.setTo(cv::Scalar(114.0/255.0, 114.0/255.0, 114.0/255.0));
canvas.setTo(cv::Scalar(114.0/255.0, 114.0/255.0, 114.0/255.0));
cv::resize(img, res, {nw, nh});
res.convertTo(res, CV_32FC3, 1.0 / 255.0);
res.convertTo(res, CV_32FC3, 1.0 / 255.0);
res.copyTo(canvas(cv::Rect(px, py, nw, nh)));
hwc_to_chw(canvas, chw_buffer.data());
@ -108,7 +108,7 @@ int main(int argc, char** argv) {
for (size_t i = 0; i < indices.size(); i++) {
int idx = indices[i];
printf(" %zu. %s (%.2f)\n", i + 1, kClassNames[class_ids[idx]].c_str(), confs[idx]);
cv::rectangle(img, bboxes[idx], {0, 255, 0}, 2);
char text[256]; std::sprintf(text, "%s %.2f", kClassNames[class_ids[idx]].c_str(), confs[idx]);
cv::putText(img, text, {bboxes[idx].x, bboxes[idx].y - 5}, cv::FONT_HERSHEY_SIMPLEX, 0.5, {0, 255, 0}, 1);

View file

@ -1,82 +1,82 @@
/*
* Copyright (C) 20242025 Amlogic, Inc. All rights reserved.
*
* 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.
*/
#include "postprocess.h"
#include <cmath>
#include <numeric>
#include <algorithm>
#include <float.h>
const std::vector<std::string> kClassNames = {
"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard",
"cell phone", "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase",
"scissors", "teddy bear", "hair drier", "toothbrush"
};
float decode_dfl(const float* dfl_ptr) {
float max_val = -FLT_MAX;
for (int i = 0; i < kDflChannels; i++) {
if (dfl_ptr[i] > max_val) max_val = dfl_ptr[i];
}
float exp_sum = 0;
float exp_vals[kDflChannels];
for (int i = 0; i < kDflChannels; i++) {
exp_vals[i] = std::exp(dfl_ptr[i] - max_val);
exp_sum += exp_vals[i];
}
float res = 0;
for (int i = 0; i < kDflChannels; i++) {
res += (exp_vals[i] / exp_sum) * i;
}
return res;
}
float calculate_iou(const cv::Rect& a, const cv::Rect& b) {
int xx1 = std::max(a.x, b.x);
int yy1 = std::max(a.y, b.y);
int xx2 = std::min(a.x + a.width, b.x + b.width);
int yy2 = std::min(a.y + a.height, b.y + b.height);
int w = std::max(0, xx2 - xx1);
int h = std::max(0, yy2 - yy1);
float inter = (float)w * h;
float areaA = (float)a.width * a.height;
float areaB = (float)b.width * b.height;
return inter / (areaA + areaB - inter);
}
std::vector<int> manual_nms(const std::vector<cv::Rect>& boxes, const std::vector<float>& scores, float thresh) {
std::vector<int> order(boxes.size());
std::iota(order.begin(), order.end(), 0);
std::stable_sort(order.begin(), order.end(), [&](int a, int b) {
return scores[a] > scores[b];
});
std::vector<int> keep;
while (!order.empty()) {
int i = order[0];
keep.push_back(i);
order.erase(order.begin());
order.erase(std::remove_if(order.begin(), order.end(), [&](int j) {
return calculate_iou(boxes[i], boxes[j]) > thresh;
}), order.end());
}
return keep;
/*
* Copyright (C) 20242025 Amlogic, Inc. All rights reserved.
*
* 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.
*/
#include "postprocess.h"
#include <cmath>
#include <numeric>
#include <algorithm>
#include <float.h>
const std::vector<std::string> kClassNames = {
"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard",
"cell phone", "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase",
"scissors", "teddy bear", "hair drier", "toothbrush"
};
float decode_dfl(const float* dfl_ptr) {
float max_val = -FLT_MAX;
for (int i = 0; i < kDflChannels; i++) {
if (dfl_ptr[i] > max_val) max_val = dfl_ptr[i];
}
float exp_sum = 0;
float exp_vals[kDflChannels];
for (int i = 0; i < kDflChannels; i++) {
exp_vals[i] = std::exp(dfl_ptr[i] - max_val);
exp_sum += exp_vals[i];
}
float res = 0;
for (int i = 0; i < kDflChannels; i++) {
res += (exp_vals[i] / exp_sum) * i;
}
return res;
}
float calculate_iou(const cv::Rect& a, const cv::Rect& b) {
int xx1 = std::max(a.x, b.x);
int yy1 = std::max(a.y, b.y);
int xx2 = std::min(a.x + a.width, b.x + b.width);
int yy2 = std::min(a.y + a.height, b.y + b.height);
int w = std::max(0, xx2 - xx1);
int h = std::max(0, yy2 - yy1);
float inter = (float)w * h;
float areaA = (float)a.width * a.height;
float areaB = (float)b.width * b.height;
return inter / (areaA + areaB - inter);
}
std::vector<int> manual_nms(const std::vector<cv::Rect>& boxes, const std::vector<float>& scores, float thresh) {
std::vector<int> order(boxes.size());
std::iota(order.begin(), order.end(), 0);
std::stable_sort(order.begin(), order.end(), [&](int a, int b) {
return scores[a] > scores[b];
});
std::vector<int> keep;
while (!order.empty()) {
int i = order[0];
keep.push_back(i);
order.erase(order.begin());
order.erase(std::remove_if(order.begin(), order.end(), [&](int j) {
return calculate_iou(boxes[i], boxes[j]) > thresh;
}), order.end());
}
return keep;
}

View file

@ -1,42 +1,42 @@
/*
* Copyright (C) 20242025 Amlogic, Inc. All rights reserved.
*
* 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.
*/
#ifndef YOLO11_POSTPROCESS_H
#define YOLO11_POSTPROCESS_H
#include <vector>
#include <string>
#include <opencv2/opencv.hpp>
static constexpr int kInputW = 640;
static constexpr int kInputH = 640;
static constexpr int kNumClasses = 80;
static constexpr int kDflChannels = 16;
static constexpr int kTotalChannels = 144;
extern const std::vector<std::string> kClassNames;
struct Detection {
cv::Rect box;
float confidence;
int class_id;
};
float decode_dfl(const float* dfl_ptr);
float calculate_iou(const cv::Rect& a, const cv::Rect& b);
std::vector<int> manual_nms(const std::vector<cv::Rect>& boxes, const std::vector<float>& scores, float thresh);
/*
* Copyright (C) 20242025 Amlogic, Inc. All rights reserved.
*
* 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.
*/
#ifndef YOLO11_POSTPROCESS_H
#define YOLO11_POSTPROCESS_H
#include <vector>
#include <string>
#include <opencv2/opencv.hpp>
static constexpr int kInputW = 640;
static constexpr int kInputH = 640;
static constexpr int kNumClasses = 80;
static constexpr int kDflChannels = 16;
static constexpr int kTotalChannels = 144;
extern const std::vector<std::string> kClassNames;
struct Detection {
cv::Rect box;
float confidence;
int class_id;
};
float decode_dfl(const float* dfl_ptr);
float calculate_iou(const cv::Rect& a, const cv::Rect& b);
std::vector<int> manual_nms(const std::vector<cv::Rect>& boxes, const std::vector<float>& scores, float thresh);
#endif

View file

@ -23,7 +23,7 @@ import cv2
from pathlib import Path
from amlnnlite.api import AMLNNLite
class_names = {0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus', 6: 'train', 7: 'truck', 8: 'boat', 9: 'traffic light', 10: 'fire hydrant', 11: 'stop sign', 12: 'parking meter', 13: 'bench', 14: 'bird', 15: 'cat', 16: 'dog', 17: 'horse', 18: 'sheep', 19: 'cow', 20: 'elephant', 21: 'bear', 22: 'zebra', 23: 'giraffe', 24: 'backpack', 25: 'umbrella', 26: 'handbag', 27: 'tie', 28: 'suitcase', 29: 'frisbee', 30: 'skis', 31: 'snowboard', 32: 'sports ball', 33: 'kite', 34: 'baseball bat', 35: 'baseball glove', 36: 'skateboard', 37: 'surfboard', 38: 'tennis racket', 39: 'bottle', 40: 'wine glass', 41: 'cup', 42: 'fork', 43: 'knife', 44: 'spoon', 45: 'bowl', 46: 'banana', 47: 'apple', 48: 'sandwich', 49: 'orange', 50: 'broccoli', 51: 'carrot', 52: 'hot dog', 53: 'pizza', 54: 'donut', 55: 'cake', 56: 'chair', 57: 'couch', 58: 'potted plant', 59: 'bed', 60: 'dining table', 61: 'toilet', 62: 'tv', 63: 'laptop', 64: 'mouse', 65: 'remote', 66: 'keyboard', 67: 'cell phone', 68: 'microwave', 69: 'oven', 70: 'toaster', 71: 'sink', 72: 'refrigerator', 73: 'book', 74: 'clock', 75: 'vase', 76: 'scissors', 77: 'teddy bear', 78: 'hair drier', 79: 'toothbrush'}
class_names = {0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus', 6: 'train', 7: 'truck', 8: 'boat', 9: 'traffic light', 10: 'fire hydrant', 11: 'stop sign', 12: 'parking meter', 13: 'bench', 14: 'bird', 15: 'cat', 16: 'dog', 17: 'horse', 18: 'sheep', 19: 'cow', 20: 'elephant', 21: 'bear', 22: 'zebra', 23: 'giraffe', 24: 'backpack', 25: 'umbrella', 26: 'handbag', 27: 'tie', 28: 'suitcase', 29: 'frisbee', 30: 'skis', 31: 'snowboard', 32: 'sports ball', 33: 'kite', 34: 'baseball bat', 35: 'baseball glove', 36: 'skateboard', 37: 'surfboard', 38: 'tennis racket', 39: 'bottle', 40: 'wine glass', 41: 'cup', 42: 'fork', 43: 'knife', 44: 'spoon', 45: 'bowl', 46: 'banana', 47: 'apple', 48: 'sandwich', 49: 'orange', 50: 'broccoli', 51: 'carrot', 52: 'hot dog', 53: 'pizza', 54: 'doughnut', 55: 'cake', 56: 'chair', 57: 'couch', 58: 'potted plant', 59: 'bed', 60: 'dining table', 61: 'toilet', 62: 'tv', 63: 'laptop', 64: 'mouse', 65: 'remote', 66: 'keyboard', 67: 'cell phone', 68: 'microwave', 69: 'oven', 70: 'toaster', 71: 'sink', 72: 'refrigerator', 73: 'book', 74: 'clock', 75: 'vase', 76: 'scissors', 77: 'teddy bear', 78: 'hair drier', 79: 'toothbrush'}
def letterbox(img, new_shape=(640, 640), color=(114, 114, 114)):
shape = img.shape[:2]