Instructions to use Cccccz/HY with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Cccccz/HY with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Cccccz/HY", 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 trainer/layers/utils.py from Cccccz/HY: direct link, hf CLI and curl.
- Browser
- Download file 738 Bytes
-
https://huggingface.co/Cccccz/HY/resolve/main/trainer/layers/utils.py
- Command line
-
hf download hf://Cccccz/HY/trainer/layers/utils.py
-
curl -L -o utils.py https://huggingface.co/Cccccz/HY/resolve/main/trainer/layers/utils.py
738 Bytes
| # SPDX-License-Identifier: Apache-2.0 | |
| # Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/layers/utils.py | |
| """Utility methods for model layers.""" | |
| import torch | |
| def get_token_bin_counts_and_mask( | |
| tokens: torch.Tensor, | |
| vocab_size: int, | |
| num_seqs: int, | |
| ) -> tuple[torch.Tensor, torch.Tensor]: | |
| # Compute the bin counts for the tokens. | |
| # vocab_size + 1 for padding. | |
| bin_counts = torch.zeros((num_seqs, vocab_size + 1), | |
| dtype=torch.long, | |
| device=tokens.device) | |
| bin_counts.scatter_add_(1, tokens, torch.ones_like(tokens)) | |
| bin_counts = bin_counts[:, :vocab_size] | |
| mask = bin_counts > 0 | |
| return bin_counts, mask | |