-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Problem
Trying to simply follow the instructions provided in readme is a mere quarter of what needs to be done.
- The installation of requirements is not straightforward as blender uses its local blender executable.
- A missing requirement.
- Torch wants a dev version of python and the libs with it.
- Addon may have been misscategorised, and Blender's python sees GenMM as a module by default.
Quick Fix
First, as of Blender 3.6.0, python version that goes with it is 3.10.12, the original source needs to be downloaded from here. It is needed for torch.
While that's downloading, Visual Studio 2022 or newer is required for building the lib, download if you don't have any.
Next, "pip" will try to install libs for the local python. The python.exe -m pip command should be used instead. Moreover, as Blender lacks python building tools, their installation/upgrade is required.
That being said:
pathtoblender/python/bin/python.exe -m pip install --upgrade pip
pathtoblender/python/bin/python.exe -m pip install --upgrade wheel
pathtoblender/python/bin/python.exe -m pip install --upgrade setuptools
pathtoblender being the path, well, to blender, for example C:\Program Files\Blender Foundation\Blender 3.6\3.6.
It is now possible to install the requirements:
pathtoblender/python/bin/python.exe -m pip install -r pathtoGenMM/docker/requirements.txt
Matplotlib may fail but is required as it is imported in init.py, to fix this it is enough to install any latest version provided by pip:
pathtoblender/python/bin/python.exe -m pip install mathplotlib
Also, Blender's python is missing a tiny requirement:
pathtoblender/python/bin/python.exe -m pip install imageio
There are no binaries provided with Python 3.10.12 (that I could find in a reasonable amount of time), hence must be compiled manually. Source code downloaded from python website earlier contains Visual Studio project files in PCbuild directory.
Open pcbuild.sln in Visual Studio, set configuration to Release, run build with Ctrl+Shift+B.
Some may fail, but that's fine. PCbuild should now contain python310.lib.
Copy files as follows:
pythonsource/Include -> pathtoblender/python/include
pythonsource/PC -> pathtoblender/python/include
python310.lib -> pathtoblender/python/libs
It should now be safe to run (referring to original readme, ${CUDA} being cu117, cu118 or cpu):
pathtoblender/python/bin/python.exe -m pip install torch-scatter==2.1.0 -f https://data.pyg.org/whl/torch-1.12.0+${CUDA}.html
The addon requires two additional fixes in init.py to be operable (at least on Windows):
Open init.py, find bl_info at around line 29, replace is with next addon description:
bl_info = {
"name" : "GenMM",
"author" : "Weiyu Li",
"description" : "Blender addon for SIGGRAPH paper 'Example-Based Motion Synthesis via Generative Motion Matching'",
"blender" : (3, 6, 0),
"version" : (0, 0, 1),
"location": "3D View",
"description": "Synthesis novel motions form a few exemplars.",
"category" : "Animation"
}
Far-far into the document at around 1255th the following line can be found:
model = GenMM(device='cuda' if torch.cuda.is_available() else 'cpu', silent=True)
Replace it with
model = GenMM.GenMM(device='cuda' if torch.cuda.is_available() else 'cpu', silent=True)
Pack the GenMM back to .zip (without compression for maximum compatibility, as Blender does not support Deflate64 compression for example) and install as addon.
It should appear in Animation category and must be enabled first.
Thereafter it should work if the parameters are set correctly.
Disclaimer: I have a negligible experience working with python and python libs, there may easily be a more proper fix that I'm not aware of. However, only after those tricks I managed to finally take the source armature from demo blender file and get a... "synsized" animation.