Fixed loading model

This commit is contained in:
Bruno Fargnoli
2025-12-20 13:30:49 +01:00
parent aba41e4d8b
commit 7b7c73f87e
3 changed files with 39 additions and 3 deletions
+28
View File
@@ -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
+1
View File
@@ -1 +1,2 @@
meshlib
requests
+10 -3
View File
@@ -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'])