fix yolov5 and classifier load single label model fail bug, and optimize cdk path check script

This commit is contained in:
Neucrack
2024-05-07 15:21:56 +08:00
parent e54e2c22e4
commit 8533c253df
4 changed files with 28 additions and 6 deletions

View File

@@ -162,12 +162,20 @@ namespace maix::nn
{
split0(labels, labels_str, ",");
}
else
else if(labels_str.find(".") != std::string::npos)
{
label_path = fs::dirname(model) + "/" + _extra_info["labels"];
err::Err e = _load_labels_from_file(labels, label_path);
if (e != err::ERR_NONE)
{
log::error("Load labels file %s failed", label_path.c_str());
return e;
}
}
else
{
labels.push_back(labels_str);
}
}
else

View File

@@ -167,12 +167,21 @@ namespace maix::nn
{
split0(labels, labels_str, ",");
}
else
else if(labels_str.find(".") != std::string::npos)
{
label_path = fs::dirname(model) + "/" + _extra_info["labels"];
err::Err e = _load_labels_from_file(labels, label_path);
if (e != err::ERR_NONE)
{
log::error("Load labels file %s failed", label_path.c_str());
return e;
}
}
else
{
labels.clear();
labels.push_back(labels_str);
}
log::print("\tlabels num: %ld\n", labels.size());
}

View File

@@ -15,7 +15,7 @@ def get_sdk_path():
# 1. get SDK absolute path from MAIXCDK_PATH env
try:
if os.environ[sdk_env_name] and os.path.exists(os.environ[sdk_env_name]):
if os.environ[sdk_env_name]:
sdk_path = os.environ[sdk_env_name]
except Exception:
pass
@@ -26,9 +26,14 @@ def get_sdk_path():
sdk_path = path
# 3. check if MaixCDK path valid
if not sdk_path or not os.path.exists(sdk_path):
if not sdk_path:
print("")
print("Error: can not find MaixCDK, please set MAIXCDK_PATH env to MaixCDK directory")
print("Error: can not find MaixCDK, please set MAIXCDK_PATH env to MaixCDK directory by `export MAIXCDK_PATH=xxxxx`")
print("")
sys.exit(1)
if not os.path.exists(sdk_path):
print("")
print(f"Error: MaixCDK set to {sdk_path}, but not exists!")
print("")
sys.exit(1)
return os.path.abspath(sdk_path)

View File

@@ -1,4 +1,4 @@
__version__ = "1.2.1"
__version__ = "1.2.2"