File size: 2,098 Bytes
82ea528 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
#__init__.py
import os
import sys
import torch
import logging
import platform
import folder_paths
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('ComfyUI-IF_Trellis')
# Add parent directory to Python path to find trellis package
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
# Add both current and parent dir to handle different installation scenarios
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
if parent_dir not in sys.path:
sys.path.insert(0, parent_dir)
# Add trellis package path
trellis_path = os.path.join(current_dir, "trellis")
if os.path.exists(trellis_path) and trellis_path not in sys.path:
sys.path.insert(0, trellis_path)
logger.info(f"Added trellis path to sys.path: {trellis_path}")
# Verify trellis package is importable
try:
import trellis
logger.info("Trellis package imported successfully")
except ImportError as e:
logger.error(f"Failed to import trellis package: {e}")
logger.error(f"Current sys.path: {sys.path}")
raise
# Register model paths with ComfyUI
try:
folder_paths.add_model_folder_path("trellis", os.path.join(folder_paths.models_dir, "trellis"))
folder_paths.add_model_folder_path("checkpoints", os.path.join(folder_paths.models_dir, "checkpoints"))
except Exception as e:
logger.error(f"Error registering model paths: {e}")
try:
from IF_TrellisCheckpointLoader import IF_TrellisCheckpointLoader
from IF_Trellis import IF_TrellisImageTo3D
NODE_CLASS_MAPPINGS = {
"IF_TrellisCheckpointLoader": IF_TrellisCheckpointLoader,
"IF_TrellisImageTo3D": IF_TrellisImageTo3D,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"IF_TrellisCheckpointLoader": "Trellis Model Loader 💾",
"IF_TrellisImageTo3D": "Trellis Image to 3D 🖼️➡️🎲",
}
except Exception as e:
logger.error(f"Error importing node classes: {e}")
raise
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] |