I can now load from an ONNX file and a make a model instance!
HOWEVER I need to be able to modify weights in memory. It seems that, in order to do this, I have to create my ONNX file in memory as there is no direct way to get and set weights in NNE?
As a precursor, I am trying to just load a known good ONNX file from disk and make a model data out of it. Whe I try to make an instance from this model data it says it can’t. Any help would be appreciated.
ModelData generating code below. I included the working one that uses the asset directly (and works) for comparison as well as the one that loads it as binary data (and doesnt produce a usable Model Data.)
FNNDataModel UNNEBlueprintInterfaceBPLibrary::FromONNXFile(FString filePath, bool& success)
{
TObjectPtr<UNNEModelData> ModelData =
LoadObject<UNNEModelData>(NULL, *filePath);
if (ModelData.IsNull())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red,
TEXT("Failed to load model data from file: " + filePath));
success = false;
}
else
{
success = true;
}
return FNNDataModel(ModelData);
}
FNNDataModel UNNEBlueprintInterfaceBPLibrary::FromONNXBytes(TArray<uint8> byteArray, bool& success)
{
TObjectPtr<UNNEModelData> ModelData = NewObject<UNNEModelData>();
ModelData->Init("onnx", MakeArrayView(byteArray.GetData(), byteArray.Num()));
if (ModelData.IsNull())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red,
TEXT("Failed to load model data from byte array"));
success = false;
}
else
{
success = true;
}
return FNNDataModel(ModelData);
}