Hi,
Please note that hailoRT and Hailo Driver are available in our developer zone and you don’t need to recompile them.
If you do use the ones from our developer zone use tappas v3.28.0
To update the postprocess update these files in your tappas repo and recompile them see instructions in: tappas/docs/write_your_own_application/compiling-your-code.rst at 4341aa360b7f8b9eac9b2d3b26f79fca562b34e4 · hailo-ai/tappas · GitHub
tappas/core/hailo/libs/postprocesses/detection/yolo_hailortpp.cpp
tappas/core/hailo/libs/postprocesses/detection/yolo_hailortpp.hpp
yolo_hailortpp.cpp
#include <regex>
#include "hailo_nms_decode.hpp"
#include "yolo_hailortpp.hpp"
#include "common/labels/coco_eighty.hpp"
static const std::string DEFAULT_YOLOV5S_OUTPUT_LAYER = "yolov5s_nv12/yolov5_nms_postprocess";
static const std::string DEFAULT_YOLOV5M_OUTPUT_LAYER = "yolov5m_wo_spp_60p/yolov5_nms_postprocess";
static const std::string DEFAULT_YOLOV5M_VEHICLES_OUTPUT_LAYER = "yolov5m_vehicles/yolov5_nms_postprocess";
static const std::string DEFAULT_YOLOV8S_OUTPUT_LAYER = "yolov8s/yolov8_nms_postprocess";
static const std::string DEFAULT_YOLOV8M_OUTPUT_LAYER = "yolov8m/yolov8_nms_postprocess";
static std::map<uint8_t, std::string> yolo_vehicles_labels = {
{0, "unlabeled"},
{1, "car"}};
void yolov5(HailoROIPtr roi)
{
if (!roi->has_tensors())
{
return;
}
auto post = HailoNMSDecode(roi->get_tensor(DEFAULT_YOLOV5M_OUTPUT_LAYER), common::coco_eighty);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
hailo_common::add_detections(roi, detections);
}
void yolov5s_nv12(HailoROIPtr roi)
{
if (!roi->has_tensors())
{
return;
}
auto post = HailoNMSDecode(roi->get_tensor(DEFAULT_YOLOV5S_OUTPUT_LAYER), common::coco_eighty);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
hailo_common::add_detections(roi, detections);
}
void yolov8s(HailoROIPtr roi)
{
if (!roi->has_tensors())
{
return;
}
auto post = HailoNMSDecode(roi->get_tensor(DEFAULT_YOLOV8S_OUTPUT_LAYER), common::coco_eighty);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
hailo_common::add_detections(roi, detections);
}
void yolov8m(HailoROIPtr roi)
{
if (!roi->has_tensors())
{
return;
}
auto post = HailoNMSDecode(roi->get_tensor(DEFAULT_YOLOV8M_OUTPUT_LAYER), common::coco_eighty);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
hailo_common::add_detections(roi, detections);
}
void yolox(HailoROIPtr roi)
{
auto post = HailoNMSDecode(roi->get_tensor("yolox_nms_postprocess"), common::coco_eighty);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
hailo_common::add_detections(roi, detections);
}
void yolov5m_vehicles(HailoROIPtr roi)
{
auto post = HailoNMSDecode(roi->get_tensor(DEFAULT_YOLOV5M_VEHICLES_OUTPUT_LAYER), yolo_vehicles_labels);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
hailo_common::add_detections(roi, detections);
}
void yolov5m_vehicles_nv12(HailoROIPtr roi)
{
if (!roi->has_tensors())
{
return;
}
auto post = HailoNMSDecode(roi->get_tensor("yolov5m_vehicles_nv12/yolov5_nms_postprocess"), yolo_vehicles_labels);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
hailo_common::add_detections(roi, detections);
}
void yolov5s_personface(HailoROIPtr roi)
{
if (!roi->has_tensors())
{
return;
}
auto post = HailoNMSDecode(roi->get_tensor("yolov5s_personface_nv12/yolov5_nms_postprocess"), common::coco_eighty);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
hailo_common::add_detections(roi, detections);
}
void yolov5_no_persons(HailoROIPtr roi)
{
auto post = HailoNMSDecode(roi->get_tensor(DEFAULT_YOLOV5M_OUTPUT_LAYER), common::coco_eighty);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
for (auto it = detections.begin(); it != detections.end();)
{
if (it->get_label() == "person")
{
it = detections.erase(it);
}
else
{
++it;
}
}
hailo_common::add_detections(roi, detections);
}
void filter(HailoROIPtr roi)
{
if (!roi->has_tensors())
{
return;
}
std::vector<HailoTensorPtr> tensors = roi->get_tensors();
// find the nms tensor
for (auto tensor : tensors)
{
if (std::regex_search(tensor->name(), std::regex("nms_postprocess")))
{
auto post = HailoNMSDecode(tensor, common::coco_eighty);
auto detections = post.decode<float32_t, common::hailo_bbox_float32_t>();
hailo_common::add_detections(roi, detections);
}
}
}
yolo_hailortpp.hpp
/**
* Copyright (c) 2021-2022 Hailo Technologies Ltd. All rights reserved.
* Distributed under the LGPL license (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt)
**/
#pragma once
#include "hailo_objects.hpp"
#include "hailo_common.hpp"
__BEGIN_DECLS
void filter(HailoROIPtr roi);
void yolov5(HailoROIPtr roi);
void yolov5s_nv12(HailoROIPtr roi);
void yolov8s(HailoROIPtr roi);
void yolov8m(HailoROIPtr roi);
void yolox(HailoROIPtr roi);
void yolov5s_personface(HailoROIPtr roi);
void yolov5_no_persons(HailoROIPtr roi);
void yolov5m_vehicles(HailoROIPtr roi);
void yolov5m_vehicles_nv12(HailoROIPtr roi);
__END_DECLS