Instructions to use OzzyGT/Pixal3D_Modular with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use OzzyGT/Pixal3D_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/Pixal3D_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 stages.py from OzzyGT/Pixal3D_Modular: direct link, hf CLI and curl.
- Browser
- Download file 2.62 kB
-
https://huggingface.co/OzzyGT/Pixal3D_Modular/resolve/main/stages.py
- Command line
-
hf download hf://OzzyGT/Pixal3D_Modular/stages.py
-
curl -L -o stages.py https://huggingface.co/OzzyGT/Pixal3D_Modular/resolve/main/stages.py
2.62 kB
| import torch | |
| from diffusers.modular_pipelines.modular_pipeline_utils import InputParam, OutputParam | |
| from .normalization import SHAPE_MEAN, SHAPE_STD, TEXTURE_MEAN, TEXTURE_STD | |
| from .resolvable import ResolvableBlock | |
| class Pixal3DShapeNormalizeStep(ResolvableBlock): | |
| model_name = "pixal3d" | |
| def description(self): | |
| return "Restore shape latents to the decoder training distribution." | |
| def inputs(self): | |
| return [InputParam("latents", required=True, type_hint=torch.Tensor, description="Denoised shape latents.")] | |
| def intermediate_outputs(self): | |
| return [OutputParam("shape_latents", type_hint=torch.Tensor, description="Shape latents for the decoder.")] | |
| def __call__(self, components, state): | |
| b = self.get_block_state(state) | |
| b.shape_latents = b.latents * b.latents.new_tensor(SHAPE_STD) + b.latents.new_tensor(SHAPE_MEAN) | |
| self.set_block_state(state, b) | |
| return components, state | |
| class Pixal3DTextureConditionStep(ResolvableBlock): | |
| model_name = "pixal3d" | |
| def description(self): | |
| return "Normalize the shape latents into the texture flow model's concatenated condition." | |
| def inputs(self): | |
| return [InputParam("shape_latents", required=True, type_hint=torch.Tensor)] | |
| def intermediate_outputs(self): | |
| return [OutputParam("concat_cond", type_hint=torch.Tensor, description="Normalized shape latents.")] | |
| def __call__(self, components, state): | |
| b = self.get_block_state(state) | |
| b.concat_cond = (b.shape_latents - b.shape_latents.new_tensor(SHAPE_MEAN)) / b.shape_latents.new_tensor( | |
| SHAPE_STD | |
| ) | |
| self.set_block_state(state, b) | |
| return components, state | |
| class Pixal3DTextureNormalizeStep(ResolvableBlock): | |
| model_name = "pixal3d" | |
| def description(self): | |
| return "Restore material latents to the decoder training distribution." | |
| def inputs(self): | |
| return [InputParam("latents", required=True, type_hint=torch.Tensor, description="Denoised material latents.")] | |
| def intermediate_outputs(self): | |
| return [ | |
| OutputParam("texture_latents", type_hint=torch.Tensor, description="Material latents for the decoder.") | |
| ] | |
| def __call__(self, components, state): | |
| b = self.get_block_state(state) | |
| b.texture_latents = b.latents * b.latents.new_tensor(TEXTURE_STD) + b.latents.new_tensor(TEXTURE_MEAN) | |
| self.set_block_state(state, b) | |
| return components, state | |