Feature Extraction
Transformers
English
remote-sensing
earth-observation
self-supervised-learning
multispectral
sar
rgb
depth
decur
resnet
vit
segformer
Instructions to use BiliSakura/DECUR-transformers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BiliSakura/DECUR-transformers with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="BiliSakura/DECUR-transformers")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("BiliSakura/DECUR-transformers", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| # Copyright 2024 The DeCUR Authors and The HuggingFace Inc. team. | |
| """DeCUR image feature extraction pipeline.""" | |
| from typing import Any, Union | |
| from transformers.pipelines.base import GenericTensor, build_pipeline_init_args | |
| from transformers.pipelines.image_feature_extraction import ImageFeatureExtractionPipeline | |
| from transformers.utils import add_end_docstrings, is_vision_available | |
| if is_vision_available(): | |
| from transformers.image_utils import load_image | |
| class DeCURImageFeatureExtractionPipeline(ImageFeatureExtractionPipeline): | |
| def _sanitize_parameters( | |
| self, | |
| image_processor_kwargs=None, | |
| return_tensors=None, | |
| pool=None, | |
| **kwargs, | |
| ): | |
| preprocess_params = {} if image_processor_kwargs is None else dict(image_processor_kwargs) | |
| if "timeout" in kwargs: | |
| preprocess_params["timeout"] = kwargs["timeout"] | |
| postprocess_params = {} | |
| if pool is not None: | |
| postprocess_params["pool"] = pool | |
| if return_tensors is not None: | |
| postprocess_params["return_tensors"] = return_tensors | |
| return preprocess_params, {}, postprocess_params | |
| def preprocess(self, image, timeout=None, **image_processor_kwargs) -> dict[str, GenericTensor]: | |
| if not isinstance(image, (list, tuple)) and not hasattr(image, "shape"): | |
| image = load_image(image, timeout=timeout) | |
| model_inputs = self.image_processor(image, return_tensors="pt", **image_processor_kwargs) | |
| model_inputs = model_inputs.to(self.dtype) | |
| return model_inputs | |
| def __call__( | |
| self, | |
| *args: Union[str, Any, list[Any]], | |
| **kwargs: Any, | |
| ) -> list[Any]: | |
| return super().__call__(*args, **kwargs) | |
| __all__ = ["DeCURImageFeatureExtractionPipeline"] | |