Any-to-Any
Transformers
Safetensors
nlduni
feature-extraction
custom_code
image-text-to-text
text-to-image
image-to-image
Instructions to use nvidia/NLD-Uni with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/NLD-Uni with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nvidia/NLD-Uni", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download utils.py from nvidia/NLD-Uni: direct link, hf CLI and curl.
- Browser
- Download file 956 Bytes
-
https://huggingface.co/nvidia/NLD-Uni/resolve/main/utils.py
- Command line
-
hf download hf://nvidia/NLD-Uni/utils.py
-
curl -L -o utils.py https://huggingface.co/nvidia/NLD-Uni/resolve/main/utils.py
956 Bytes
| # ADOBE CONFIDENTIAL | |
| # Copyright 2025 Adobe | |
| # All Rights Reserved. | |
| # NOTICE: All information contained herein is, and remains | |
| # the property of Adobe and its suppliers, if any. The intellectual | |
| # and technical concepts contained herein are proprietary to Adobe | |
| # and its suppliers and are protected by all applicable intellectual | |
| # property laws, including trade secret and copyright laws. | |
| # Dissemination of this information or reproduction of this material | |
| # is strictly forbidden unless prior written permission is obtained | |
| # from Adobe. | |
| from __future__ import annotations | |
| import torch | |
| def pad_along_last_dim(x, size): | |
| pad_size = size - x.shape[-1] | |
| if pad_size == 0: | |
| return x | |
| padding = torch.zeros(*x.shape[:-1], pad_size, dtype=x.dtype, device=x.device) | |
| x_padded = torch.cat([x, padding], dim=-1) | |
| return x_padded | |
| def maybe_truncate_last_dim(x, size): | |
| if size == x.shape[-1]: | |
| return x | |
| return x[..., :size] | |