Views
No views yet

conda create -n cad python=3.10conda activate cadpip install cad-diffusion1from cad import CADT2IPipeline
2
3pipe = CADT2IPipeline("nicolas-dufour/CAD_256").to("cuda")
4
5prompt = "An avocado armchair"
6
7image = pipe(prompt, cfg=15)1from cad import CAD
2
3model = CAD.from_pretrained("nicolas-dufour/CAD_256")CADT2IPipeline class provides a comprehensive interface for generating images from text prompts. Here's a detailed guide on how to use it:1from cad import CADT2IPipeline
2
3# Initialize the pipeline
4pipe = CADT2IPipeline("nicolas-dufour/CAD_512").to("cuda")
5
6# Generate an image from a prompt
7prompt = "An avocado armchair"
8image = pipe(prompt, cfg=15)1pipe = CADT2IPipeline(
2 model_path="nicolas-dufour/CAD_512",
3 sampler="ddim", # Options: "ddim", "ddpm", "dpm", "dpm_2S", "dpm_2M"
4 scheduler="sigmoid", # Options: "sigmoid", "cosine", "linear"
5 postprocessing="sd_1_5_vae", # Options: "consistency-decoder", "sd_1_5_vae"
6 scheduler_start=-3,
7 scheduler_end=3,
8 scheduler_tau=1.1,
9 device="cuda"
10)__call__ method accepts various parameters to control the generation process:1image = pipe(
2 cond="A beautiful landscape", # Text prompt or list of prompts
3 num_samples=4, # Number of images to generate
4 cfg=15, # Classifier-free guidance scale
5 guidance_type="constant", # Type of guidance: "constant", "linear"
6 guidance_start_step=0, # Step to start guidance
7 coherence_value=1.0, # Coherence value for sampling
8 uncoherence_value=0.0, # Uncoherence value for sampling
9 thresholding_type="clamp", # Type of thresholding: "clamp", "dynamic_thresholding", "per_channel_dynamic_thresholding"
10 clamp_value=1.0, # Clamp value for thresholding
11 thresholding_percentile=0.995 # Percentile for thresholding
12)constant: Applies uniform guidance throughout the sampling processlinear: Linearly increases guidance strength from start to endexponential: Exponentially increases guidance strength from start to endclamp: Clamps values to a fixed range using clamp_valuedynamic: Dynamically adjusts thresholds based on the batch statisticspercentile: Uses percentile-based thresholding with thresholding_percentilex_N: Initial noise tensorlatents: Previous latents for continuationnum_steps: Custom number of sampling stepssampler: Custom sampler functionscheduler: Custom scheduler functionguidance_start_step: Step to start guidancegenerator: Random number generator for reproducibilityunconfident_prompt: Custom unconfident prompt text1@article{dufour2024dont,
2 title={Don’t drop your samples! Coherence-aware training benefits Conditional diffusion},
3 author={Nicolas Dufour and Victor Besnier and Vicky Kalogeiton and David Picard},
4 journal={CVPR}
5 year={2024}
6}