Download vit_encoder.py from safiaa02/ChestGPT: direct link, hf CLI and curl.
- Browser
- Download file 313 Bytes
-
https://huggingface.co/spaces/safiaa02/ChestGPT/resolve/main/vit_encoder.py
- Command line
-
hf download hf://spaces/safiaa02/ChestGPT/vit_encoder.py
-
curl -L -o vit_encoder.py https://huggingface.co/spaces/safiaa02/ChestGPT/resolve/main/vit_encoder.py
313 Bytes
| from torchvision import models | |
| import torch.nn as nn | |
| class ViTEncoder(nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| self.vit = models.vit_b_16(weights="IMAGENET1K_V1") | |
| self.vit.heads = nn.Identity() # remove classifier head | |
| def forward(self, x): | |
| return self.vit(x) | |