Closed edargham closed 2 years ago
After a lot of trial and error here's the working version of this function:
inputB64
was turned into an LHS value.decode_base64()
back to decode_jpeg()
Here is the updated version:
const char* ClassifierModel::outputB64(const char* inputB64)
{
try
{
std::string b64{ inputB64 };
cppflow::tensor input{ cppflow::decode_jpeg(cppflow::decode_base64(b64)) };
input = cppflow::cast(input, TF_UINT8, TF_FLOAT);
input = input / 255.f;
input = cppflow::expand_dims(input, 0);
input = cppflow::resize_bicubic(input, cppflow::tensor({ 75, 150 }), true);
cppflow::tensor out{ clfModel(input) };
cppflow::tensor result{ cppflow::arg_max(out, 1) };
std::vector<long long int> data{ result.get_data<long long int>() };
const long long int idx{ data[0] };
return classes.at(idx).c_str();
}
catch (std::exception ex)
{
throw ex;
}
}
I'm trying to pass a base64 encoded image as input into the model, however the API throws an exception whenever I do. There is no usage example in the docs, does anyone knows where this is going wrong? Here's the code:
Edits: Code block layout.