mirror of
https://github.com/sipeed/MaixCDK.git
synced 2026-11-09 17:04:38 -06:00
optmize some basic API like log,memory_info,fs.join
This commit is contained in:
@@ -183,6 +183,14 @@ namespace maix::fs
|
||||
*/
|
||||
std::vector<std::string> *listdir(const std::string &path, bool recursive = false, bool full_path = false);
|
||||
|
||||
/**
|
||||
* Join paths
|
||||
* @param paths paths to join
|
||||
* @return joined path if success, empty string if failed
|
||||
* @maixpy maix.fs.join
|
||||
*/
|
||||
std::string join(const std::vector<std::string> &paths);
|
||||
|
||||
/**
|
||||
* File read write ops
|
||||
* @maixpy maix.fs.File
|
||||
|
||||
@@ -14,6 +14,42 @@
|
||||
|
||||
namespace maix::log
|
||||
{
|
||||
/**
|
||||
* Error log level enums
|
||||
* @maixpy maix.log.LogLevel
|
||||
*/
|
||||
enum class LogLevel
|
||||
{
|
||||
LEVEL_NONE = 0,
|
||||
LEVEL_ERROR,
|
||||
LEVEL_WARN,
|
||||
LEVEL_INFO,
|
||||
LEVEL_DEBUG,
|
||||
LEVEL_MAX
|
||||
};
|
||||
|
||||
/**
|
||||
* Set log level globally, by default log level is LEVEL_INFO.
|
||||
* @param level log level, @see maix.log.LogLevel
|
||||
* @param color true to enable color, false to disable color
|
||||
* @maixpy maix.log.set_log_level
|
||||
*/
|
||||
void set_log_level(log::LogLevel level, bool color);
|
||||
|
||||
/**
|
||||
* Get current log level
|
||||
* @return current log level
|
||||
* @maixpy maix.log.get_log_level
|
||||
*/
|
||||
log::LogLevel get_log_level();
|
||||
|
||||
/**
|
||||
* Get whether log use color
|
||||
* @return true if log use color, else false
|
||||
* @maixpy maix.log.get_log_use_color
|
||||
*/
|
||||
bool get_log_use_color();
|
||||
|
||||
/**
|
||||
* print error log
|
||||
* @param fmt format string
|
||||
@@ -80,6 +116,7 @@ namespace maix::log
|
||||
void debug0(const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* DEPRACATED, DO NOT USE THIS method.
|
||||
* same as printf, but recommend use this function instead of printf
|
||||
* this function will add prefix like "-- [E] " to log
|
||||
* @param fmt format string
|
||||
@@ -88,6 +125,15 @@ namespace maix::log
|
||||
*/
|
||||
void print(const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* print log info with specified log level, no '\n' at end and no prefix like "-- [E] ".
|
||||
* this function will add prefix like "-- [E] " to log
|
||||
* @param fmt format string
|
||||
* @param ... args
|
||||
* @maixcdk maix.log.print
|
||||
*/
|
||||
void print(log::LogLevel level, const char *fmt, ...);
|
||||
|
||||
} // namespace maix::log
|
||||
|
||||
|
||||
|
||||
@@ -105,6 +105,10 @@ namespace maix::sys
|
||||
* used: used memory size in Byte.
|
||||
* hw_total: total memory size in Byte of hardware, the total <= hw_total,
|
||||
* OS kernel may reserve some memory for some hardware like camera, npu, display etc.
|
||||
* custom_total: Board or Chip custom memory management area. For example, for MaixCAM is IOA, for MaixCAM2 is CMM.
|
||||
* custom_used: Board or Chip custom memory management area used size.
|
||||
* cma_total: Contiguous Memory Allocator (Linux CMA standard) total size in Byte.
|
||||
* cma_used: Contiguous Memory Allocator (Linux CMA standard) used size in Byte.
|
||||
* @maixpy maix.sys.memory_info
|
||||
*/
|
||||
std::map<std::string, int64_t> memory_info();
|
||||
|
||||
@@ -254,6 +254,17 @@ namespace maix::fs
|
||||
return list;
|
||||
}
|
||||
|
||||
std::string join(const std::vector<std::string> &paths)
|
||||
{
|
||||
// join paths use fs_sys::path::operator/
|
||||
fs_sys::path p;
|
||||
for (auto &path : paths)
|
||||
{
|
||||
p /= path;
|
||||
}
|
||||
return p.string();
|
||||
}
|
||||
|
||||
fs::File *open(const std::string &path, const std::string &mode)
|
||||
{
|
||||
err::Err error = err::ERR_NONE;
|
||||
|
||||
@@ -14,9 +14,29 @@ namespace maix::log
|
||||
{
|
||||
|
||||
static char log_buf[512];
|
||||
static volatile LogLevel log_level = LogLevel::LEVEL_INFO;
|
||||
static volatile bool log_color = false;
|
||||
|
||||
void set_log_level(LogLevel level, bool color)
|
||||
{
|
||||
log_level = level;
|
||||
log_color = color;
|
||||
}
|
||||
|
||||
LogLevel get_log_level()
|
||||
{
|
||||
return log_level;
|
||||
}
|
||||
|
||||
bool get_log_use_color()
|
||||
{
|
||||
return log_color;
|
||||
}
|
||||
|
||||
void error(const char *fmt, ...)
|
||||
{
|
||||
if(log_level < LogLevel::LEVEL_ERROR)
|
||||
return;
|
||||
static const char *err_start = "-- [E] ";
|
||||
// print error and call err::set_error
|
||||
va_list args;
|
||||
@@ -30,6 +50,8 @@ namespace maix::log
|
||||
|
||||
void error0(const char *fmt, ...)
|
||||
{
|
||||
if(log_level < LogLevel::LEVEL_ERROR)
|
||||
return;
|
||||
static const char *err_start = "-- [E] ";
|
||||
// print error and call err::set_error
|
||||
va_list args;
|
||||
@@ -43,6 +65,8 @@ namespace maix::log
|
||||
|
||||
void warn(const char *fmt, ...)
|
||||
{
|
||||
if(log_level < LogLevel::LEVEL_WARN)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printf("-- [W] ");
|
||||
@@ -53,6 +77,8 @@ namespace maix::log
|
||||
|
||||
void warn0(const char *fmt, ...)
|
||||
{
|
||||
if(log_level < LogLevel::LEVEL_WARN)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printf("-- [W] ");
|
||||
@@ -62,6 +88,8 @@ namespace maix::log
|
||||
|
||||
void info(const char *fmt, ...)
|
||||
{
|
||||
if(log_level < LogLevel::LEVEL_INFO)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printf("-- [I] ");
|
||||
@@ -72,6 +100,8 @@ namespace maix::log
|
||||
|
||||
void info0(const char *fmt, ...)
|
||||
{
|
||||
if(log_level < LogLevel::LEVEL_INFO)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printf("-- [I] ");
|
||||
@@ -82,6 +112,8 @@ namespace maix::log
|
||||
void debug(const char *fmt, ...)
|
||||
{
|
||||
#if DEBUG
|
||||
if(log_level < LogLevel::LEVEL_DEBUG)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printf("-- [D] ");
|
||||
@@ -96,6 +128,8 @@ namespace maix::log
|
||||
void debug0(const char *fmt, ...)
|
||||
{
|
||||
#if DEBUG
|
||||
if(log_level < LogLevel::LEVEL_DEBUG)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printf("-- [D] ");
|
||||
@@ -108,6 +142,17 @@ namespace maix::log
|
||||
|
||||
void print(const char *fmt, ...)
|
||||
{
|
||||
printf("[WARN] log::print(fmt, ...) function is deprecated, please use log::print(log::LogLevel, fmt, ...) instead\n");
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void print(LogLevel level, const char *fmt, ...)
|
||||
{
|
||||
if(level > log_level)
|
||||
return;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
|
||||
@@ -487,7 +487,9 @@ namespace maix::sys
|
||||
|
||||
fclose(file);
|
||||
|
||||
res["cma_total"] = 0;
|
||||
res["custom_total"] = 0; // Board or Chip custom memory management area. For MaixCAM is IOA, for MaixCAM2 is CMM.
|
||||
res["custom_used"] = 0;
|
||||
res["cma_total"] = 0; // Contiguous Memory Allocator (Linux CMA standard)
|
||||
res["cma_used"] = 0;
|
||||
res["used"] = (total_memory - free_memory) * 1024;
|
||||
res["total"] = total_memory * 1024;
|
||||
@@ -519,9 +521,9 @@ namespace maix::sys
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
res["cma_total"] = total_cmm_memory;
|
||||
res["cma_used"] = used_cmm_memory;
|
||||
res["hw_total"] = (res["total"] + total_cmm_memory) * 1024;
|
||||
res["custom_total"] = total_cmm_memory * 1024;
|
||||
res["custom_used"] = used_cmm_memory * 1024;
|
||||
res["hw_total"] = res["total"] + total_cmm_memory * 1024;
|
||||
if (res["hw_total"] > (int64_t)3.9 * 1024 * 1024 * 1024 && res["hw_total"] < (int64_t)4.1 * 1024 * 1024 * 1024)
|
||||
res["hw_total"] = (int64_t)4 * 1024 * 1024 * 1024; // 4G version
|
||||
else if (res["hw_total"] > 0.9 * 1024 * 1024 * 1024 && res["hw_total"] < 1.1 * 1024 * 1024 * 1024)
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace maix::nn
|
||||
|
||||
/**
|
||||
* If layer layout, if layout is chw, typically the shape is [N, C, H, W], hwc is [N, H, W, C].
|
||||
* @maixpy maix.nn.Layout
|
||||
* @maixpy maix.nn.LayerInfo.layout
|
||||
*/
|
||||
nn::Layout layout = nn::Layout::UNKNOWN;
|
||||
|
||||
|
||||
@@ -95,12 +95,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -117,7 +117,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -129,9 +129,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -142,7 +142,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -154,9 +154,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -168,7 +168,7 @@ namespace maix::nn
|
||||
_input_size = image::Size(inputs[0].shape[2], inputs[0].shape[1]);
|
||||
else
|
||||
_input_size = image::Size(inputs[0].shape[3], inputs[0].shape[2]);
|
||||
log::print("\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
|
||||
// decoder params
|
||||
// priorbox
|
||||
|
||||
@@ -134,12 +134,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -156,7 +156,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -168,9 +168,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -181,7 +181,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -193,9 +193,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -208,7 +208,7 @@ namespace maix::nn
|
||||
_input_size = image::Size(inputs[0].shape[2], inputs[0].shape[1]);
|
||||
else
|
||||
_input_size = image::Size(inputs[0].shape[3], inputs[0].shape[2]);
|
||||
log::print("\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
for(auto &l : outputs)
|
||||
{
|
||||
if(l.name.find("points") != std::string::npos)
|
||||
|
||||
@@ -421,12 +421,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -443,7 +443,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info2["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -455,9 +455,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->mean_feature.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->mean_feature.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -468,7 +468,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info2["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -480,9 +480,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->scale_feature.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->scale_feature.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -99,12 +99,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -121,7 +121,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -133,9 +133,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -146,7 +146,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -158,9 +158,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -170,7 +170,7 @@ namespace maix::nn
|
||||
err::Err e = _model->extra_info_labels(labels);
|
||||
if (e == err::Err::ERR_NONE)
|
||||
{
|
||||
log::print("\tlabels num: %ld\n", labels.size());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tlabels num: %ld\n", labels.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -199,7 +199,7 @@ namespace maix::nn
|
||||
else
|
||||
_input_size = image::Size(inputs[0].shape[3], inputs[0].shape[2]);
|
||||
_input_size_detect = image::Size(inputs_detect[0].shape[2], inputs_detect[0].shape[1]);
|
||||
log::print("\tinput size: %dx%d\n\n", _input_size_detect.width(), _input_size_detect.height());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput size: %dx%d\n\n", _input_size_detect.width(), _input_size_detect.height());
|
||||
|
||||
// anchors
|
||||
if (_extra_info.find("anchors") != _extra_info.end())
|
||||
|
||||
@@ -97,12 +97,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -119,7 +119,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -131,9 +131,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -143,7 +143,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -155,9 +155,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -205,7 +205,7 @@ namespace maix::nn
|
||||
_input_size = image::Size(inputs[0].shape[3], inputs[0].shape[2]);
|
||||
inputs = _model_target->inputs_info();
|
||||
_input_size_target = image::Size(inputs[0].shape[3], inputs[0].shape[2]);
|
||||
log::print("\tinput size: %dx%d, target size: %dx%d\n\n", _input_size.width(), _input_size.height(), _input_size_target.width(), _input_size_target.height());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput size: %dx%d, target size: %dx%d\n\n", _input_size.width(), _input_size.height(), _input_size_target.width(), _input_size_target.height());
|
||||
return err::ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,12 +104,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -129,13 +129,13 @@ namespace maix::nn
|
||||
{
|
||||
this->det = true;
|
||||
this->rec = false;
|
||||
log::print("\tdet: true\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tdet: true\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->det = false;
|
||||
this->rec = true;
|
||||
log::print("\tdet: false\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tdet: false\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -147,7 +147,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -162,9 +162,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->det ? this->mean.back() : this->rec_mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->det ? this->mean.back() : this->rec_mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else if(!this->rec)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -190,9 +190,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->det ? this->scale.back() : this->rec_scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->det ? this->scale.back() : this->rec_scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else if(!this->rec)
|
||||
{
|
||||
@@ -204,7 +204,7 @@ namespace maix::nn
|
||||
_input_size = image::Size(inputs[0].shape[2], inputs[0].shape[1]);
|
||||
else
|
||||
_input_size = image::Size(inputs[0].shape[3], inputs[0].shape[2]);
|
||||
log::print("\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
|
||||
// rec model
|
||||
if (_extra_info.find("rec_model") != _extra_info.end())
|
||||
@@ -215,7 +215,7 @@ namespace maix::nn
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
std::string rec_model = fs::dirname(model) + "/" + _extra_info["rec_model"];
|
||||
log::print("\trec_model: %s\n", rec_model.c_str());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\trec_model: %s\n", rec_model.c_str());
|
||||
_rec_model = new nn::NN(rec_model, false);
|
||||
if (!_rec_model)
|
||||
{
|
||||
@@ -235,7 +235,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["rec_mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\trec_mean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\trec_mean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -247,15 +247,15 @@ namespace maix::nn
|
||||
log::error("rec_mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->rec_mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->rec_mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
if (_extra_info.find("rec_scale") != _extra_info.end())
|
||||
{
|
||||
std::string scale_str = _extra_info["rec_scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\trec_scale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\trec_scale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -267,9 +267,9 @@ namespace maix::nn
|
||||
log::error("rec_scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->rec_scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->rec_scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
if(this->rec_scale.empty() || this->rec_mean.empty())
|
||||
{
|
||||
@@ -280,7 +280,7 @@ namespace maix::nn
|
||||
err::Err e = _model->extra_info_labels(labels);
|
||||
if(e == err::Err::ERR_NONE)
|
||||
{
|
||||
log::print("\tlabels num: %ld\n", labels.size());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tlabels num: %ld\n", labels.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -101,12 +101,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -123,7 +123,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -135,9 +135,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -148,7 +148,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -160,9 +160,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -171,7 +171,7 @@ namespace maix::nn
|
||||
}
|
||||
std::vector<nn::LayerInfo> inputs = _model->inputs_info();
|
||||
_input_size = image::Size(inputs[0].shape[3], inputs[0].shape[2]);
|
||||
log::print("\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
|
||||
// decoder params
|
||||
_config.variance[0] = 0.1;
|
||||
|
||||
@@ -164,12 +164,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -186,7 +186,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -198,9 +198,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -211,7 +211,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -223,9 +223,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -235,7 +235,7 @@ namespace maix::nn
|
||||
err::Err e = _model->extra_info_labels(labels);
|
||||
if(e == err::Err::ERR_NONE)
|
||||
{
|
||||
log::print("\tlabels num: %ld\n", labels.size());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tlabels num: %ld\n", labels.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -271,7 +271,7 @@ namespace maix::nn
|
||||
_input_size = image::Size(inputs[0].shape[2], inputs[0].shape[1]);
|
||||
else
|
||||
_input_size = image::Size(inputs[0].shape[3], inputs[0].shape[2]);
|
||||
log::print("\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
|
||||
// output info
|
||||
_out_chw = true;
|
||||
@@ -285,7 +285,7 @@ namespace maix::nn
|
||||
log::info("Outputs:");
|
||||
for(auto item : outputs)
|
||||
{
|
||||
log::print(" %s\n", item.to_str().c_str());
|
||||
log::print(log::LogLevel::LEVEL_INFO, " %s\n", item.to_str().c_str());
|
||||
}
|
||||
};
|
||||
// mode 1
|
||||
|
||||
@@ -149,12 +149,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -171,7 +171,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -183,9 +183,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -196,7 +196,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -208,9 +208,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -243,9 +243,9 @@ namespace maix::nn
|
||||
log::error("labels num not match, model expect %d, but code expect %d", _labels_num, (int)this->labels.size());
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("\tinput size: %dx%d\n", _input_size.width(), _input_size.height());
|
||||
log::print("\ttext feature num: %d\n", _text_feature_num);
|
||||
log::print("\tlabels num: %d\n\n", _labels_num);
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput size: %dx%d\n", _input_size.width(), _input_size.height());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\ttext feature num: %d\n", _text_feature_num);
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tlabels num: %d\n\n", _labels_num);
|
||||
|
||||
if(_input_text_feature)
|
||||
delete _input_text_feature;
|
||||
@@ -287,7 +287,7 @@ namespace maix::nn
|
||||
log::info("Outputs:");
|
||||
for(auto item : outputs)
|
||||
{
|
||||
log::print(" %s\n", item.to_str().c_str());
|
||||
log::print(log::LogLevel::LEVEL_INFO, " %s\n", item.to_str().c_str());
|
||||
}
|
||||
};
|
||||
if(outputs.size() != 3)
|
||||
|
||||
@@ -95,12 +95,12 @@ namespace maix::nn
|
||||
if (input_type == "rgb")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_RGB888;
|
||||
log::print("\tinput type: rgb\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: rgb\n");
|
||||
}
|
||||
else if (input_type == "bgr")
|
||||
{
|
||||
_input_img_fmt = maix::image::FMT_BGR888;
|
||||
log::print("\tinput type: bgr\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput type: bgr\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -117,7 +117,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string mean_str = _extra_info["mean"];
|
||||
std::vector<std::string> mean_strs = split(mean_str, ",");
|
||||
log::print("\tmean:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tmean:");
|
||||
for (auto &it : mean_strs)
|
||||
{
|
||||
try
|
||||
@@ -129,9 +129,9 @@ namespace maix::nn
|
||||
log::error("mean value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->mean.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->mean.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -142,7 +142,7 @@ namespace maix::nn
|
||||
{
|
||||
std::string scale_str = _extra_info["scale"];
|
||||
std::vector<std::string> scale_strs = split(scale_str, ",");
|
||||
log::print("\tscale:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tscale:");
|
||||
for (auto &it : scale_strs)
|
||||
{
|
||||
try
|
||||
@@ -154,9 +154,9 @@ namespace maix::nn
|
||||
log::error("scale value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%f ", this->scale.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f ", this->scale.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -166,7 +166,7 @@ namespace maix::nn
|
||||
err::Err e = _model->extra_info_labels(labels);
|
||||
if(e == err::Err::ERR_NONE)
|
||||
{
|
||||
log::print("\tlabels num: %ld\n", labels.size());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tlabels num: %ld\n", labels.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -178,7 +178,7 @@ namespace maix::nn
|
||||
std::string &anchors_str = _extra_info["anchors"];
|
||||
std::vector<std::string> anchors_strs;
|
||||
split0(anchors_strs, anchors_str, ",");
|
||||
log::print("\tanchors:");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tanchors:");
|
||||
for (auto &it : anchors_strs)
|
||||
{
|
||||
try
|
||||
@@ -190,9 +190,9 @@ namespace maix::nn
|
||||
log::error("anchors value error, should float");
|
||||
return err::ERR_ARGS;
|
||||
}
|
||||
log::print("%.2f ", this->anchors.back());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%.2f ", this->anchors.back());
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
if (this->anchors.size() % 2 != 0)
|
||||
{
|
||||
log::error("anchors value error, should even");
|
||||
@@ -209,7 +209,7 @@ namespace maix::nn
|
||||
_input_size = image::Size(inputs[0].shape[2], inputs[0].shape[1]);
|
||||
else
|
||||
_input_size = image::Size(inputs[0].shape[3], inputs[0].shape[2]);
|
||||
log::print("\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\tinput size: %dx%d\n\n", _input_size.width(), _input_size.height());
|
||||
return err::ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace maix::nn
|
||||
if (model_path.empty() || !fs::exists(model_path.c_str()))
|
||||
{
|
||||
log::error("model path %s not exists\n", model_path.c_str());
|
||||
return err::ERR_ARGS;
|
||||
return err::ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
if(model_path.find(".mud") == std::string::npos)
|
||||
@@ -231,7 +231,7 @@ namespace maix::nn
|
||||
if(model_path.empty() || !fs::exists(model_path))
|
||||
{
|
||||
log::error("model path %s not exists\n", model_path.c_str());
|
||||
return err::ERR_ARGS;
|
||||
return err::ERR_NOT_FOUND;
|
||||
}
|
||||
err::Err e = _mud.load(model_path);
|
||||
if (e != err::ERR_NONE)
|
||||
|
||||
@@ -31,12 +31,12 @@ int _main(int argc, char* argv[])
|
||||
if(rx_len > 0)
|
||||
{
|
||||
log::info("received %d: \"%s\"\n", rx_len, rx_buff);
|
||||
log::print("hex:\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "hex:\n");
|
||||
for(int i=0; i < rx_len; ++i)
|
||||
{
|
||||
log::print("%02x ", rx_buff[i]);
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%02x ", rx_buff[i]);
|
||||
}
|
||||
log::print("\n\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n\n");
|
||||
serial.write(rx_buff, rx_len);
|
||||
log::info("sent %d: \"%s\"\n", rx_len, rx_buff);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ int _main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// printf args info
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
log::info("model path: %s", model_path);
|
||||
log::info("image path: %s", img_path);
|
||||
log::info("model type: %s", model_type.c_str());
|
||||
@@ -159,15 +159,15 @@ int _main(int argc, char* argv[])
|
||||
log::info("mean: ");
|
||||
for(auto &it : mean)
|
||||
{
|
||||
log::print("%f, ", it);
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f, ", it);
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
log::info("scale: ");
|
||||
for(auto &it : scale)
|
||||
{
|
||||
log::print("%f, ", it);
|
||||
log::print(log::LogLevel::LEVEL_INFO, "%f, ", it);
|
||||
}
|
||||
log::print("\n");
|
||||
log::print(log::LogLevel::LEVEL_INFO, "\n");
|
||||
|
||||
std::vector<nn::LayerInfo> inputs_info = model.inputs_info();
|
||||
for(auto &it : inputs_info)
|
||||
|
||||
@@ -49,12 +49,12 @@ int _main(int argc, char* argv[])
|
||||
log::info("Inputs:");
|
||||
for(auto item : inputs_info)
|
||||
{
|
||||
log::print(" %s\n", item.to_str().c_str());
|
||||
log::print(log::LogLevel::LEVEL_INFO, " %s\n", item.to_str().c_str());
|
||||
}
|
||||
log::info("Outputs:");
|
||||
for(auto item : outputs_info)
|
||||
{
|
||||
log::print(" %s\n", item.to_str().c_str());
|
||||
log::print(log::LogLevel::LEVEL_INFO, " %s\n", item.to_str().c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -97,11 +97,11 @@ int _main(int argc, char* argv[])
|
||||
{
|
||||
tensor::Tensor *tensor = it.second;
|
||||
log::info("======= output '%s':", it.first.c_str());
|
||||
log::print(" info: %s\n",(*tensor).to_str().c_str());
|
||||
log::print(log::LogLevel::LEVEL_INFO, " info: %s\n",(*tensor).to_str().c_str());
|
||||
|
||||
auto names = split(it.first, "/");
|
||||
std::string filename = names[names.size() - 1] + ".bin";
|
||||
log::print(" save as bin file to '%s'\n", filename.c_str());
|
||||
log::print(log::LogLevel::LEVEL_INFO, " save as bin file to '%s'\n", filename.c_str());
|
||||
fs::File *f = fs::open(filename, "wb");
|
||||
if(!f)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user