Text-to-Image
Diffusers
Safetensors
English
Chinese
flow-matching
qwen-image
ascend
lora
recursive-self-improvement
Instructions to use DALabCommunity/Haidass-Image-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use DALabCommunity/Haidass-Image-Instruct with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("DALabCommunity/Haidass-Image-Base-v1_0.6B_512px", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("DALabCommunity/Haidass-Image-Instruct") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Download runtime/normalization.py from DALabCommunity/Haidass-Image-Instruct: direct link, hf CLI and curl.
- Browser
- Download file 916 Bytes
-
https://huggingface.co/DALabCommunity/Haidass-Image-Instruct/resolve/main/runtime/normalization.py
- Command line
-
hf download hf://DALabCommunity/Haidass-Image-Instruct/runtime/normalization.py
-
curl -L -o normalization.py https://huggingface.co/DALabCommunity/Haidass-Image-Instruct/resolve/main/runtime/normalization.py
916 Bytes
| """RMS normalization with device-specific dispatch.""" | |
| import torch | |
| from torch import nn | |
| class RMSNorm(nn.Module): | |
| def __init__(self, dim, eps): | |
| super().__init__() | |
| self.weight = nn.Parameter(torch.ones(dim)) | |
| self.eps = eps | |
| def forward(self, hidden_states): | |
| low_precision_weight = self.weight.dtype in (torch.float16, torch.bfloat16) | |
| if hidden_states.device.type == 'npu': | |
| import torch_npu | |
| if low_precision_weight: | |
| hidden_states = hidden_states.to(self.weight.dtype) | |
| return torch_npu.npu_rms_norm(hidden_states, self.weight, epsilon=self.eps)[0] | |
| variance = hidden_states.float().pow(2).mean(-1, keepdim=True) | |
| normalized = hidden_states * torch.rsqrt(variance+self.eps) | |
| if low_precision_weight: | |
| normalized = normalized.to(self.weight.dtype) | |
| return normalized*self.weight | |