Instructions to use rajlab/condensatenet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rajlab/condensatenet with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="rajlab/condensatenet", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("rajlab/condensatenet", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add configuration code for trust_remote_code
Browse files
configuration_condensatenet.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""CondensateNet Configuration"""
|
| 2 |
+
|
| 3 |
+
from transformers import PretrainedConfig
|
| 4 |
+
from typing import Tuple
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class CondensateNetConfig(PretrainedConfig):
|
| 8 |
+
"""
|
| 9 |
+
Configuration for CondensateNet.
|
| 10 |
+
|
| 11 |
+
Stores all hyperparameters needed to reconstruct the model architecture.
|
| 12 |
+
|
| 13 |
+
Args:
|
| 14 |
+
encoder_variant: EfficientNetV2 variant to use (default: "rw_s")
|
| 15 |
+
pyramid_channels: Channel dimensions for FPN levels
|
| 16 |
+
pyramid_dim: Dimension of FPN feature maps
|
| 17 |
+
use_spatial_attention: Whether to use sparse spatial attention
|
| 18 |
+
spatial_kernel_size: Kernel size for spatial attention
|
| 19 |
+
dropout_rate: Dropout rate for regularization
|
| 20 |
+
num_classes: Number of output classes (1 for binary segmentation)
|
| 21 |
+
"""
|
| 22 |
+
model_type = "condensatenet"
|
| 23 |
+
|
| 24 |
+
def __init__(
|
| 25 |
+
self,
|
| 26 |
+
encoder_variant: str = "rw_s",
|
| 27 |
+
pyramid_channels: Tuple[int, ...] = (24, 48, 64, 160),
|
| 28 |
+
pyramid_dim: int = 32,
|
| 29 |
+
use_spatial_attention: bool = True,
|
| 30 |
+
spatial_kernel_size: int = 11,
|
| 31 |
+
dropout_rate: float = 0.15,
|
| 32 |
+
num_classes: int = 1,
|
| 33 |
+
**kwargs
|
| 34 |
+
):
|
| 35 |
+
super().__init__(**kwargs)
|
| 36 |
+
self.encoder_variant = encoder_variant
|
| 37 |
+
self.pyramid_channels = list(pyramid_channels)
|
| 38 |
+
self.pyramid_dim = pyramid_dim
|
| 39 |
+
self.use_spatial_attention = use_spatial_attention
|
| 40 |
+
self.spatial_kernel_size = spatial_kernel_size
|
| 41 |
+
self.dropout_rate = dropout_rate
|
| 42 |
+
self.num_classes = num_classes
|