how do i insert multiple images in one generation with this model?
- User
how do i insert multiple images in one generation with this model?
Assistant
The TRELLIS model supports multi-image input for a single 3D generation. This functionality is implemented through the
run_multi_imagefunction in theTrellisImageTo3DPipelineclass. Here's a breakdown of how to use it:- Load the Pipeline: Start by loading the pre-trained pipeline:
pythonimport os #Optional environment variables (see below for details) #os.environ['ATTN_BACKEND'] = 'xformers' #os.environ['SPCONV_ALGO'] = 'native' from PIL import Image from trellis.pipelines import TrellisImageTo3DPipeline pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large") pipeline.cuda()- Load and Preprocess Images: Load your images using PIL's
Image.open. It's crucial to preprocess each image using the pipeline's built-in preprocessing function:
pythonimages = [ Image.open("path/to/image1.png"), Image.open("path/to/image2.png"), Image.open("path/to/image3.png"), ] processed_images = [pipeline.preprocess_image(image) for image in images]- Run the Pipeline with Multiple Images: Use the
run_multi_imagefunction, providing the list of preprocessed images:
pythonoutputs = pipeline.run_multi_image( processed_images, seed=1, # Set a seed for reproducibility sparse_structure_sampler_params={ "steps": 12, # Adjust as needed "cfg_strength": 7.5, # Adjust as needed }, slat_sampler_params={ "steps": 12, # Adjust as needed "cfg_strength": 3, # Adjust as needed }, mode="stochastic" # Or "multidiffusion", see explanation below )
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.