- Introduced `onnx_moge2.py` for MoGe-2 ONNX inference with NumPy post-processing. - Added `onnx_ben2.py` for BEN2 ONNX inference with Pillow and NumPy preprocessing. - Created `onnx_da3.py` for Depth Anything 3 inference with ONNX Runtime and NumPy. - Implemented shared ONNX Runtime session helpers in `onnx_runtime.py`. - Developed unit tests for server functionalities in `test_server.py`, including model caching and job management. - Enhanced job server to handle frame extraction without requiring models.
55 lines
1.2 KiB
Python
55 lines
1.2 KiB
Python
from pathlib import Path
|
|
|
|
import bpy
|
|
|
|
from .blendjob import BlenderJobRuntime
|
|
from .server import server
|
|
|
|
|
|
DEFAULT_STORAGE_ROOT = Path.home() / ".snapform"
|
|
|
|
|
|
def configured_storage_root():
|
|
addon = bpy.context.preferences.addons.get(__package__)
|
|
configured = getattr(getattr(addon, "preferences", None), "storage_root", "")
|
|
if configured:
|
|
return Path(bpy.path.abspath(configured))
|
|
return DEFAULT_STORAGE_ROOT
|
|
|
|
|
|
ENVIRONMENT = {
|
|
"python": "3.12",
|
|
"packages": [
|
|
"numpy==2.4.2",
|
|
"pillow==12.1.1",
|
|
"av==17.0.0",
|
|
"trimesh==4.11.2",
|
|
"huggingface-hub==1.4.1",
|
|
],
|
|
"platform_packages": {
|
|
"windows": ["onnxruntime-directml==1.24.4"],
|
|
"default": ["onnxruntime==1.24.4"],
|
|
},
|
|
}
|
|
|
|
|
|
def post_install(job_runtime):
|
|
errors = []
|
|
for model in ("MOGE2_VITS_NORMAL", "BEN2_BASE"):
|
|
try:
|
|
job_runtime.request("download-model", {"model": model})
|
|
except RuntimeError as error:
|
|
errors.append(str(error))
|
|
if errors:
|
|
raise RuntimeError("; ".join(errors))
|
|
|
|
|
|
runtime = BlenderJobRuntime(
|
|
server,
|
|
storage_root=configured_storage_root,
|
|
environment=ENVIRONMENT,
|
|
post_install=post_install,
|
|
)
|
|
|
|
JobOperatorBase = runtime.JobOperatorBase
|