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
File size: 1,467 Bytes
586325c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | """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()
|