Instructions to use devin-lai/Hi3Dv1.0-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use devin-lai/Hi3Dv1.0-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download devin-lai/Hi3Dv1.0-mlx --local-dir Hi3Dv1.0-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download src/sparc3d/utils/misc.py from devin-lai/Hi3Dv1.0-mlx: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/devin-lai/Hi3Dv1.0-mlx/resolve/main/src/sparc3d/utils/misc.py
- Command line
-
hf download hf://devin-lai/Hi3Dv1.0-mlx/src/sparc3d/utils/misc.py
-
curl -L -o misc.py https://huggingface.co/devin-lai/Hi3Dv1.0-mlx/resolve/main/src/sparc3d/utils/misc.py
1.8 kB
| """Batch/offset conversions and structure cloning helpers.""" | |
| # Adapted from Pointcept / Point Transformer V3 under the MIT License. | |
| # Modified for SPARC3D to retain the batch/offset trio used by the decoder. | |
| from __future__ import annotations | |
| from copy import deepcopy | |
| from typing import Any | |
| import torch | |
| def offset2bincount(offset: torch.Tensor) -> torch.Tensor: | |
| """Return the per-batch point counts implied by a cumulative ``offset``.""" | |
| return torch.diff( | |
| offset, prepend=torch.tensor([0], device=offset.device, dtype=torch.long) | |
| ) | |
| def offset2batch(offset: torch.Tensor) -> torch.Tensor: | |
| """Expand a cumulative ``offset`` into a per-point batch index.""" | |
| bincount = offset2bincount(offset) | |
| return torch.arange( | |
| len(bincount), device=offset.device, dtype=torch.long | |
| ).repeat_interleave(bincount) | |
| def batch2offset(batch: torch.Tensor) -> torch.Tensor: | |
| """Reduce a per-point batch index into a cumulative ``offset``.""" | |
| return torch.cumsum(batch.bincount(), dim=0).long() | |
| def deep_clone(value: Any) -> Any: | |
| """Copy a nested container, sharing tensors rather than duplicating them. | |
| Tensors are passed through by reference: the point structures this backs are | |
| cloned per network stage and copying multi-million-element features at every | |
| stage would dominate decoder memory. | |
| """ | |
| if isinstance(value, dict): | |
| return {key: deep_clone(item) for key, item in value.items()} | |
| if isinstance(value, list): | |
| return [deep_clone(item) for item in value] | |
| if isinstance(value, tuple): | |
| return tuple(deep_clone(item) for item in value) | |
| if isinstance(value, torch.Tensor): | |
| return value | |
| return deepcopy(value) | |