Enhance device management and model handling in SnapForm

- Updated frame extraction logic to allow for single frame extraction.
- Integrated model readiness checks for BEN2 and DA3 models in relevant operators.
- Added directory name attribute to model specifications for better organization.
- Improved device selection logic for production and debug tasks.
- Refactored preferences to expose device settings and ensure they reflect available hardware.
- Enhanced runtime device detection and management, including support for CUDA and MPS.
- Updated tests to cover new device management features and model directory handling.
- Removed deprecated download model tests to streamline codebase.
This commit is contained in:
2026-08-08 20:16:11 +08:00
parent aee460fe7f
commit 9c896213a5
18 changed files with 699 additions and 196 deletions

View File

@@ -1,9 +1,9 @@
import shutil
import sys
from pathlib import Path
import bpy
from .runtime import device_enum_items
class SnapFormPreferences(bpy.types.AddonPreferences):
bl_idname = __package__
@@ -17,31 +17,14 @@ class SnapFormPreferences(bpy.types.AddonPreferences):
subtype="DIR_PATH",
default=str(Path.home() / ".snapform"),
)
uv_executable: bpy.props.StringProperty(
name="uv Executable",
device: bpy.props.EnumProperty(
name="Device",
description=(
"Path to uv; leave empty to auto-download a standalone uv "
"when it is missing"
"Inference device used by production tasks; only devices supported "
"on this machine are listed"
),
subtype="FILE_PATH",
default=shutil.which("uv") or "",
)
torch_backend: bpy.props.EnumProperty(
name="Torch Backend",
description="PyTorch build installed into the isolated Runtime",
items=(
("CU128", "CUDA 12.8", "NVIDIA CUDA 12.8 PyTorch wheels"),
("CPU", "CPU", "CPU-only PyTorch wheels"),
),
default="CPU" if sys.platform == "darwin" else "CU128",
)
pypi_index_url: bpy.props.StringProperty(
name="PyPI Index",
description=(
"Package index for the isolated Runtime; leave empty to auto-detect "
"with mirror fallback. Example: https://pypi.tuna.tsinghua.edu.cn/simple"
),
default="",
items=device_enum_items,
default=0,
)
def draw(self, _context):
@@ -50,9 +33,7 @@ class SnapFormPreferences(bpy.types.AddonPreferences):
layout = self.layout
layout.prop(self, "storage_root")
layout.prop(self, "uv_executable")
layout.prop(self, "torch_backend")
layout.prop(self, "pypi_index_url")
layout.prop(self, "device")
layout.separator()
layout.label(text=f"Runtime: {runtime_directory()}")
if runtime_ready():