Open DefTruth opened 2 years ago
#include "lite/lite.h" static void test_default() { std::string head_seg_onnx_path = "../../../hub/onnx/cv/minivision_head_seg.onnx"; std::string cartoon_onnx_path = "../../../hub/onnx/cv/minivision_female_photo2cartoon.onnx"; std::string test_img_path = "../../../examples/lite/resources/test_lite_female_photo2cartoon.jpg"; std::string save_mask_path = "../../../logs/test_lite_female_photo2cartoon_seg.jpg"; std::string save_cartoon_path = "../../../logs/test_lite_female_photo2cartoon_cartoon.jpg"; auto *head_seg = new lite::cv::segmentation::HeadSeg(head_seg_onnx_path, 4); // 4 threads auto *female_photo2cartoon = new lite::cv::style::FemalePhoto2Cartoon(cartoon_onnx_path, 4); // 4 threads lite::types::HeadSegContent head_seg_content; cv::Mat img_bgr = cv::imread(test_img_path); head_seg->detect(img_bgr, head_seg_content); if (head_seg_content.flag && !head_seg_content.mask.empty()) { cv::imwrite(save_mask_path, head_seg_content.mask * 255.f); // Female Photo2Cartoon Style Transfer lite::types::FemalePhoto2CartoonContent female_cartoon_content; female_photo2cartoon->detect(img_bgr, head_seg_content.mask, female_cartoon_content); if (female_cartoon_content.flag && !female_cartoon_content.cartoon.empty()) cv::imwrite(save_cartoon_path, female_cartoon_content.cartoon); } delete head_seg; delete female_photo2cartoon; }
the output is:
add MNN/TNN/ONNXRuntime C++ demo:
usage
the output is: