Instructions to use OzzyGT/Kimodo_SOMA_Modular with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use OzzyGT/Kimodo_SOMA_Modular with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("OzzyGT/Kimodo_SOMA_Modular", 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
Download before_denoise.py from OzzyGT/Kimodo_SOMA_Modular: direct link, hf CLI and curl.
- Browser
- Download file 2.88 kB
-
https://huggingface.co/OzzyGT/Kimodo_SOMA_Modular/resolve/main/before_denoise.py
- Command line
-
hf download hf://OzzyGT/Kimodo_SOMA_Modular/before_denoise.py
-
curl -L -o before_denoise.py https://huggingface.co/OzzyGT/Kimodo_SOMA_Modular/resolve/main/before_denoise.py
2.88 kB
| import torch | |
| from diffusers import ModelMixin, SchedulerMixin | |
| from diffusers.modular_pipelines.modular_pipeline_utils import ComponentSpec, InputParam, OutputParam | |
| from diffusers.utils.torch_utils import randn_tensor | |
| from .operations import ResolvableBlock | |
| class KimodoLatentsStep(ResolvableBlock): | |
| model_name = "kimodo" | |
| def description(self): | |
| return "Draw the initial motion-feature noise for an explicit frame count." | |
| def expected_components(self): | |
| return self.resolve([ComponentSpec("transformer", ModelMixin)]) | |
| def inputs(self): | |
| return [ | |
| InputParam( | |
| "num_frames", type_hint=int, default=120, description="Motion samples at the model frame rate." | |
| ), | |
| InputParam( | |
| "seed", | |
| type_hint=int, | |
| default=42, | |
| description="Seed for a generator on the execution device; ignored when `generator` is given.", | |
| ), | |
| InputParam.template("generator"), | |
| ] | |
| def intermediate_outputs(self): | |
| return [ | |
| OutputParam("latents", type_hint=torch.Tensor, description="Noisy motion features, (1, frames, features).") | |
| ] | |
| def __call__(self, components, state): | |
| block = self.get_block_state(state) | |
| if block.num_frames < 2: | |
| raise ValueError("Motion requires at least two frames") | |
| device = components._execution_device | |
| generator = block.generator | |
| if generator is None: | |
| generator = torch.Generator(device=device).manual_seed(block.seed) | |
| transformer = components.transformer | |
| block.latents = randn_tensor( | |
| (1, block.num_frames, transformer.motion_rep_dim), | |
| generator=generator, | |
| device=device, | |
| dtype=transformer.dtype, | |
| ) | |
| self.set_block_state(state, block) | |
| return components, state | |
| class KimodoTimestepsStep(ResolvableBlock): | |
| model_name = "kimodo" | |
| def description(self): | |
| return "Set the Kimodo DDIM schedule for this run." | |
| def expected_components(self): | |
| return self.resolve([ComponentSpec("scheduler", SchedulerMixin)]) | |
| def inputs(self): | |
| return [InputParam.template("num_inference_steps", default=100)] | |
| def intermediate_outputs(self): | |
| return [OutputParam("timesteps", type_hint=torch.Tensor, description="Descending training-step indices.")] | |
| def __call__(self, components, state): | |
| block = self.get_block_state(state) | |
| components.scheduler.set_timesteps(block.num_inference_steps, device=components._execution_device) | |
| block.timesteps = components.scheduler.timesteps | |
| self.set_block_state(state, block) | |
| return components, state | |