ML Deformer couldn't load network

Hello,

I’ve found two similar posts on your forums but no replies that seemed to solve the issue.

and

I’ve been working through the ML Cloth Generation tutorials but in 5.4 preview and keep tripping up at the final hurdle. Training seems to complete without error but then I get the dialog message
“Training completed but resulting network couldn’t be loaded!”

Output log as below

LogPython: Calculating inputs and outputs took 127 seconds.
LogPython: write to ../../../../../../Work/MDD/cloth_5_4_1/Intermediate/NearestNeighborModel//inputs.npy
LogPython: Model successfully trained.
LogPython: export to ../../../../../../Work/MDD/cloth_5_4_1/Intermediate/NearestNeighborModel//NearestNeighborModel.pt
LogScript: Error: Script Msg: Traceback (most recent call last):
  File "C:/Program Files/Epic Games/UE_5.4/Engine/Plugins/Animation/MLDeformer/NearestNeighborModel/Content/Python/init_unreal.py", line 21, in train
    return nearestneighbormodel.train(self)
  File "C:\Program Files/Epic Games/UE_5.4/Engine/Plugins/Animation/MLDeformer/NearestNeighborModel/Content/Python\nearestneighbormodel.py", line 1283, in train
    inputs._mmap.close()
AttributeError: 'numpy.ndarray' object has no attribute '_mmap'
LogScript: Error: Script call stack:
    /Engine/PythonTypes.NearestNeighborPythonTrainingModel.Train
LogMLDeformer: Display: Training duration: 00:16:15 (HH:MM:SS)
LogNearestNeighborModel: Error: Network file 'C:/Work/MDD/cloth_5_4_1/Intermediate/NearestNeighborModel/NearestNeighborModel.ubnne' does not exist!

I checked the Intermediate folder for output ( cloth_5_4_1\Intermediate\NearestNeighborModel ) and can see a deltas.bin file which is roughly 2 gig, inputs.npy 1 meg and NearestNeighborModel.pt at 55 megs.

No sign of the .ubnne.

I peppered the train function with some logs for some further tests and everything appears to complete correctly apart from the last step. Any help gladly received.

Cheers!

A little more digging today seems to confirm it’s just the missing _mmap property causing issues as the python script wasn’t handling the error and so the save_ubnne_network method was never called.

By wrapping the error the training appears to complete correctly and the .ubnne file is created.

Python edit on nearestneighbormodel.py located in UE_5.4\Engine\Plugins\Animation\MLDeformer\NearestNeighborModel\Content\Python
This is within the train method at ln1296

finally:
        if 'train_data' in locals():
            inputs, outputs = train_data
            if isinstance(outputs, np.memmap):
                # inputs._mmap doesn't seem to exist, so wrapping in a try/except so that the network is saved when an error fires
                try:
                    inputs._mmap.close()
                except Exception as e:
                    ue.log_error("MARK:: ERROR")
                    ue.log_error(e)
            del inputs, outputs

            torch.cuda.empty_cache()

Leaving this as unresolved for the moment.