Unconditional Image Generation
Diffusers
Safetensors
English
lightningdit
image-generation
class-conditional
imagenet
flow-matching
Instructions to use BiliSakura/LightningDiT-diffusers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use BiliSakura/LightningDiT-diffusers with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("BiliSakura/LightningDiT-diffusers", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Update LightningDit-XL-1-256/scheduler/scheduling_flow_match_lightningdit.py
Browse files3 unmodified lines4567891032 unmodified lines43444546474849505152536 unmodified lines606162636465666768694 unmodified lines7475767778798013 unmodified lines9495969798991003 unmodified lines# you may not use this file except in compliance with the License.from dataclasses import dataclassfrom typing import Optional, Tupleimport torch32 unmodified linesorder = 1@register_to_configdef __init__(self, path_type: str = "linear", num_train_timesteps: int = 1000):if path_type not in {"linear", "cosine"}:raise ValueError("path_type must be either 'linear' or 'cosine'.")self.path_type = path_typeself.num_train_timesteps = num_train_timestepsself.timesteps = torch.linspace(0.0, 1.0, num_train_timesteps + 1, dtype=torch.float64)@staticmethod6 unmodified linesself,num_inference_steps: int,device: Optional[torch.device] = None,timestep_shift: float = 0.0,):timesteps = torch.linspace(0.0, 1.0, num_inference_steps + 1, dtype=torch.float64)timesteps = self._apply_timestep_shift(timesteps, timestep_shift)self.timesteps = timesteps.to(device=device)return self.timesteps4 unmodified linessample: torch.Tensor,next_timestep: torch.Tensor,return_dict: bool = True,) -> LightningDiTFlowMatchSchedulerOutput:sample_dtype = sample.dtypesample = sample.to(dtype=torch.float64)model_output = model_output.to(dtype=torch.float64)13 unmodified linessample: torch.Tensor,next_timestep: torch.Tensor,return_dict: bool = True,) -> LightningDiTFlowMatchSchedulerOutput:sample_dtype = sample.dtypesample = sample.to(dtype=torch.float64)model_output = model_output.to(dtype=torch.float64)3 unmodified lines4567891032 unmodified lines43444546474849505152535455565758596 unmodified lines66676869707172737475764 unmodified lines81828384858687888913 unmodified lines1031041051061071081091101113 unmodified lines# you may not use this file except in compliance with the License.from dataclasses import dataclassfrom typing import List, Optional, Tuple, Unionimport torch32 unmodified linesorder = 1@register_to_configdef __init__(self,path_type: str = "linear",num_train_timesteps: int = 1000,shift: float = 0.3,):if path_type not in {"linear", "cosine"}:raise ValueError("path_type must be either 'linear' or 'cosine'.")self.path_type = path_typeself.num_train_timesteps = num_train_timestepsself.shift = shiftself.timesteps = torch.linspace(0.0, 1.0, num_train_timesteps + 1, dtype=torch.float64)@staticmethod6 unmodified linesself,num_inference_steps: int,device: Optional[torch.device] = None,timestep_shift: Optional[float] = None,):shift = self.shift if timestep_shift is None else timestep_shifttimesteps = torch.linspace(0.0, 1.0, num_inference_steps + 1, dtype=torch.float64)timesteps = self._apply_timestep_shift(timesteps, shift)self.timesteps = timesteps.to(device=device)return self.timesteps4 unmodified linessample: torch.Tensor,next_timestep: torch.Tensor,return_dict: bool = True,generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,) -> LightningDiTFlowMatchSchedulerOutput:del generatorsample_dtype = sample.dtypesample = sample.to(dtype=torch.float64)model_output = model_output.to(dtype=torch.float64)13 unmodified linessample: torch.Tensor,next_timestep: torch.Tensor,return_dict: bool = True,generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,) -> LightningDiTFlowMatchSchedulerOutput:del generatorsample_dtype = sample.dtypesample = sample.to(dtype=torch.float64)model_output = model_output.to(dtype=torch.float64)
LightningDit-XL-1-256/scheduler/scheduling_flow_match_lightningdit.py+15-4