# pipe\_backbone

## Function: pipe\_backbone

```python
def pipe_backbone(backbone: str = "resnet18") -> Tuple[torch.nn.Module, int]
```

### Description

The `pipe_backbone` function is a helper function that provides a simple interface to create different backbone models for feature extraction. It supports a variety of common models including different ResNet architectures, EfficientNet, MobileNet, and Vision Transformer.

### Parameters

* `backbone` (str, default="resnet18"): Specifies the type of the backbone model to be created. Possible values include:
  * "resnet18": ResNet-18 architecture without pretrained weights.
  * "resnet18\_pretrained": ResNet-18 architecture with pretrained weights.
  * "resnet50": ResNet-50 architecture without pretrained weights.
  * "resnet50\_pretrained": ResNet-50 architecture with pretrained weights.
  * "efficientnet\_b5": EfficientNet-B5 architecture without pretrained weights.
  * "efficientnet\_b5\_pretrained": EfficientNet-B5 architecture with pretrained weights.
  * "mobilenet\_v3": MobileNetV3-Large architecture without pretrained weights.
  * "mobilenet\_v3\_pretrained": MobileNetV3-Large architecture with pretrained weights.
  * "vit\_64": Vision Transformer architecture suitable for 64x64 images.
  * "vit\_224": Vision Transformer architecture suitable for 224x224 images.

### Returns

The function returns a tuple where the first element is a PyTorch `nn.Module` representing the backbone model and the second element is an integer indicating the size of the output feature vector from the backbone model.

### Examples

To get a ResNet-18 model without pretrained weights:

```python
backbone_model, out_dim = pipe_backbone("resnet18")
```

To get a Vision Transformer model suitable for 224x224 images:

```python
backbone_model, out_dim = pipe_backbone("vit_224")
```

### Use Cases

* **Creating backbone models**: This function simplifies the process of creating different backbone models. The output of this function can be used as the backbone in other models.
* **Feature Extraction**: The backbone models created using this function can be used to extract features from images. These features can then be used in other downstream tasks like clustering or classification.
* **Transfer Learning**: The backbone models, especially the ones with pretrained weights, can be used for transfer learning.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://autossl.gitbook.io/autossl/api/model/pipe_backbone.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
