amaye15 commited on
Commit
44be74d
1 Parent(s): c433e44

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +47 -0
  2. upolad_to_hub.py +14 -0
README.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # DaViT Model
3
+
4
+ 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.
5
+
6
+ ## Model Description
7
+
8
+ 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.
9
+
10
+ ### Example
11
+
12
+ Here is an example of how to use the DaViT model for image classification:
13
+
14
+ ```python
15
+ import torch
16
+ from transformers import AutoModel, AutoConfig
17
+
18
+ # Load the configuration and model
19
+ config = AutoConfig.from_pretrained("your-username/DaViT")
20
+ model = AutoModel.from_pretrained("your-username/DaViT")
21
+
22
+ # Generate a random sample input tensor with shape (batch_size, channels, height, width)
23
+ batch_size = 2
24
+ channels = 3
25
+ height = 224
26
+ width = 224
27
+ sample_input = torch.randn(batch_size, channels, height, width)
28
+
29
+ # Pass the sample input through the model
30
+ output = model(sample_input)
31
+
32
+ # Print the output shape
33
+ print(f"Output shape: {output.shape}")
34
+ ```
35
+
36
+ ## Files
37
+
38
+ - `configuration_davit.py`: Contains the `DaViTConfig` class.
39
+ - `modeling_davit.py`: Contains the `DaViTModel` class.
40
+ - `test_davit_model.py`: Script to test the model.
41
+ - `config.json`: Configuration file for the model.
42
+ - `model.safetensors`: Pretrained weights of the DaViT model.
43
+
44
+ ## Credits
45
+
46
+ 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).
47
+
upolad_to_hub.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # from huggingface_hub import create_repo
2
+ # create_repo("amaye15/DaViT")
3
+
4
+ from huggingface_hub import HfApi
5
+
6
+ api = HfApi()
7
+
8
+ # Upload all the content from the local folder to your remote Space.
9
+ # By default, files are uploaded at the root of the repo
10
+ api.upload_folder(
11
+ folder_path="/Users/andrewmayes/Dev/DaViT/DaViT",
12
+ repo_id="amaye15/DaViT",
13
+ repo_type="model",
14
+ )