File size: 1,677 Bytes
44be74d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b2a8724
 
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
39
40
41
42
43
44
45
46
47
48

# DaViT Model

This repository contains the implementation of the DaViT (Dual-Attention Vision Transformer) model for image classification tasks. The model leverages dual attention mechanisms to improve performance on various image datasets.

## Model Description

DaViT (Dual-Attention Vision Transformer) is designed to handle image classification tasks effectively. It combines spatial and channel attention mechanisms to capture intricate details in images. The model has multiple stages, each with convolutional embeddings and attention blocks.

### Example

Here is an example of how to use the DaViT model for image classification:

```python
import torch
from transformers import AutoModel, AutoConfig

# Load the configuration and model
config = AutoConfig.from_pretrained("your-username/DaViT")
model = AutoModel.from_pretrained("your-username/DaViT")

# Generate a random sample input tensor with shape (batch_size, channels, height, width)
batch_size = 2
channels = 3
height = 224
width = 224
sample_input = torch.randn(batch_size, channels, height, width)

# Pass the sample input through the model
output = model(sample_input)

# Print the output shape
print(f"Output shape: {output.shape}")
```

## Files

- `configuration_davit.py`: Contains the `DaViTConfig` class.
- `modeling_davit.py`: Contains the `DaViTModel` class.
- `test_davit_model.py`: Script to test the model.
- `config.json`: Configuration file for the model.
- `model.safetensors`: Pretrained weights of the DaViT model.

## Credits

This model is inspired by and builds upon the ideas presented in the [Florence-2-large model by Microsoft](https://huggingface.co./microsoft/Florence-2-large).