diff --git a/nodes.py b/nodes.py index affc416..b75e9c3 100644 --- a/nodes.py +++ b/nodes.py @@ -112,6 +112,34 @@ class Trellis2LoadModel: if not os.path.exists(dinov3_model_path): raise Exception("Facebook Dinov3 model not found in models/facebook/dinov3-vitl16-pretrain-lvd1689m folder") + trellis_image_large_path = os.path.join(folder_paths.models_dir,"microsoft","Trellis-Image-Large","ckpts","ss_dec_conv3d_16l8_fp16.safetensors") + if not os.path.exists(trellis_image_large_path): + print('Trellis-Image-Large ss_dec_conv3d_16l8_fp16 files not found. Trying to download the files from huggingface ...') + import requests + url = "https://huggingface.co/microsoft/TRELLIS-image-large/resolve/main/ckpts/ss_dec_conv3d_16l8_fp16.json?download=true" + filename = os.path.join(folder_paths.models_dir,"microsoft","Trellis-Image-Large","ckpts","ss_dec_conv3d_16l8_fp16.json") + path = Path(filename) + path.parent.mkdir(parents=True, exist_ok=True) + + response = requests.get(url) + if response.status_code == 200: + with open(filename, "wb") as f: + f.write(response.content) + print("Download ss_dec_conv3d_16l8_fp16.json complete!") + else: + raise Exception("Cannot download Trellis-Image-Large file ss_dec_conv3d_16l8_fp16.json") + + url = "https://huggingface.co/microsoft/TRELLIS-image-large/resolve/main/ckpts/ss_dec_conv3d_16l8_fp16.safetensors?download=true" + filename = os.path.join(folder_paths.models_dir,"microsoft","Trellis-Image-Large","ckpts","ss_dec_conv3d_16l8_fp16.safetensors") + + response = requests.get(url) + if response.status_code == 200: + with open(filename, "wb") as f: + f.write(response.content) + print("Download ss_dec_conv3d_16l8_fp16.safetensors complete!") + else: + raise Exception("Cannot download Trellis-Image-Large file ss_dec_conv3d_16l8_fp16.safetensors") + pipeline = Trellis2ImageTo3DPipeline.from_pretrained(model_path) pipeline.low_vram = low_vram diff --git a/requirements.txt b/requirements.txt index a1831cd..a389626 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ meshlib +requests diff --git a/trellis2/pipelines/trellis2_image_to_3d.py b/trellis2/pipelines/trellis2_image_to_3d.py index 1c2f16b..12a50c5 100644 --- a/trellis2/pipelines/trellis2_image_to_3d.py +++ b/trellis2/pipelines/trellis2_image_to_3d.py @@ -49,8 +49,12 @@ class Trellis2ImageTo3DPipeline(Pipeline): ): if models is None: return + + if os.name=='nt': + models['sparse_structure_decoder'] = os.path.join(folder_paths.models_dir,"microsoft","TRELLIS-image-large","ckpts","ss_dec_conv3d_16l8_fp16") + else: + models['sparse_structure_decoder'] = os.path.join("models","microsoft","TRELLIS-image-large","ckpts","ss_dec_conv3d_16l8_fp16") - #models['sparse_structure_decoder'] = os.path.join("microsoft","TRELLIS-image-large","ckpts","ss_dec_conv3d_16l8_fp16.safetensors") super().__init__(models) self.sparse_structure_sampler = sparse_structure_sampler self.shape_slat_sampler = shape_slat_sampler @@ -97,8 +101,11 @@ class Trellis2ImageTo3DPipeline(Pipeline): new_pipeline.shape_slat_normalization = args['shape_slat_normalization'] new_pipeline.tex_slat_normalization = args['tex_slat_normalization'] - #facebook_model_path = os.path.join(folder_paths.models_dir,"facebook","dinov3-vitl16-pretrain-lvd1689m") - facebook_model_path = os.path.join("models","facebook","dinov3-vitl16-pretrain-lvd1689m") + if os.name == 'nt': + facebook_model_path = os.path.join(folder_paths.models_dir,"facebook","dinov3-vitl16-pretrain-lvd1689m") + else: + facebook_model_path = os.path.join("models","facebook","dinov3-vitl16-pretrain-lvd1689m") + args['image_cond_model']['args']['model_name'] = facebook_model_path new_pipeline.image_cond_model = getattr(image_feature_extractor, args['image_cond_model']['name'])(**args['image_cond_model']['args'])