Feature Extraction
Transformers
Safetensors
English
lessvit
hyperspectral
remote-sensing
geospatial
vision-transformer
custom_code
Instructions to use GFM-Bench/LESSViT-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GFM-Bench/LESSViT-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="GFM-Bench/LESSViT-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("GFM-Bench/LESSViT-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download modeling_lessvit.py from GFM-Bench/LESSViT-Base: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/GFM-Bench/LESSViT-Base/resolve/main/modeling_lessvit.py
- Command line
-
hf download hf://GFM-Bench/LESSViT-Base/modeling_lessvit.py
-
curl -L -o modeling_lessvit.py https://huggingface.co/GFM-Bench/LESSViT-Base/resolve/main/modeling_lessvit.py
1.47 kB
| """Hugging Face interface for the original LESSViT encoder.""" | |
| # Explicit dependencies let Transformers copy the full local/remote module tree. | |
| from .pos_chan_embed import RopePositionChannelEmbedding | |
| from .hyperspectral_patch_embed import HyperspectralPatchEmbed | |
| from .low_rank_attention import LowRankAttention | |
| from .attention_ops import LowRankBlock | |
| from .spatial_spectral_low_rank_vit import ( | |
| SpatialSpectralLowRankViTConfig, | |
| SpatialSpectralLowRankViTEncoder, | |
| ) | |
| class LESSViTConfig(SpatialSpectralLowRankViTConfig): | |
| model_type = "lessvit" | |
| def __init__(self, channel_embed_dims_per_head=2, **kwargs): | |
| # The original config constructor recomputes these derived dimensions. | |
| kwargs.pop("channel_dim", None) | |
| kwargs.pop("spatial_dim", None) | |
| kwargs.pop("pretrain", None) | |
| kwargs.pop("mask_ratio", None) | |
| kwargs.pop("channel_mask_ratio", None) | |
| kwargs.pop("channel_dropout", None) | |
| super().__init__(channel_embed_dims_per_head=channel_embed_dims_per_head, | |
| mask_ratio=0.0, channel_mask_ratio=0.0, | |
| channel_dropout=None, **kwargs) | |
| self.channel_embed_dims_per_head = channel_embed_dims_per_head | |
| self.pretrain = False | |
| class LESSViTModel(SpatialSpectralLowRankViTEncoder): | |
| config_class = LESSViTConfig | |
| main_input_name = "optical" | |
| def __init__(self, config): | |
| super().__init__(config) | |
| self.post_init() | |