Invalid first argument to `register()`. ForwardRef('PredictedInstance') is not a class.
In Python 3.9+, it looks like cattrs breaks when structuring forward references. At the moment this only affects M1 Macs which will use Python 3.9 environments by default, but will be an issue across all platforms in the future.
This crops up when loading a project that has an instance created from predictions such that the Instance.from_predicted field is not None (i.e., set to a PredictedInstance). Here's where this is handled:
https://github.com/talmolab/sleap/blob/be89412e3a352ae68a0ed717c142d9b680c2eda9/sleap/instance.py#L1228-L1249
This can be worked around using the approach described in https://github.com/python-attrs/cattrs/issues/206.
See below for original user post that reported this.
Discussed in https://github.com/talmolab/sleap/discussions/966
Originally posted by gaojundong September 20, 2022 Hi Team,
When I try to save the skeleton instance as a new project, a window suddenly popped up to remind me:
An error occured when attempting to save:
Invalid first argument to register(). ForwardRef('PredictedInstance') is not a class.
Try saving your project with a different filename or in a different format.
I try to modify the file name as label.slp and label.v001.slp, but it still doesn't work. this is my software version: Software versions: SLEAP: 1.2.8 TensorFlow: 2.9.2 Numpy: 1.22.3 Python: 3.9.13 OS: macOS-12.5.1-arm64-arm-64bit
In this software, I can save skeleton node and edges and export video, but I don't know where is the problem when I save the whole project. Can you give me some hints about this. Thank you very much.
All the best, Gaojun