Update README.md
Browse files
README.md
CHANGED
@@ -6,7 +6,58 @@ tags: []
|
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
## Model Details
|
|
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
+
## Code to create model
|
10 |
+
```python
|
11 |
+
import torch
|
12 |
+
from transformers import GroundingDinoConfig, GroundingDinoForObjectDetection, AutoProcessor
|
13 |
+
|
14 |
+
model_id = 'IDEA-Research/grounding-dino-tiny'
|
15 |
+
config = GroundingDinoConfig.from_pretrained(
|
16 |
+
model_id,
|
17 |
+
decoder_layers=1,
|
18 |
+
decoder_attention_heads=2,
|
19 |
+
encoder_layers=1,
|
20 |
+
encoder_attention_heads=2,
|
21 |
+
text_config=dict(
|
22 |
+
num_attention_heads=2,
|
23 |
+
num_hidden_layers=1,
|
24 |
+
hidden_size=32,
|
25 |
+
),
|
26 |
+
backbone_config=dict(
|
27 |
+
attention_probs_dropout_prob=0.0,
|
28 |
+
depths=[1, 1, 2, 1],
|
29 |
+
drop_path_rate=0.1,
|
30 |
+
embed_dim=12,
|
31 |
+
encoder_stride=32,
|
32 |
+
hidden_act="gelu",
|
33 |
+
hidden_dropout_prob=0.0,
|
34 |
+
hidden_size=48,
|
35 |
+
image_size=224,
|
36 |
+
initializer_range=0.02,
|
37 |
+
layer_norm_eps=1e-05,
|
38 |
+
mlp_ratio=4.0,
|
39 |
+
num_channels=3,
|
40 |
+
num_heads=[1, 2, 3, 4],
|
41 |
+
num_layers=4,
|
42 |
+
out_features=["stage2", "stage3", "stage4"],
|
43 |
+
out_indices=[2, 3, 4],
|
44 |
+
patch_size=4,
|
45 |
+
stage_names=["stem", "stage1", "stage2", "stage3", "stage4"],
|
46 |
+
window_size=7
|
47 |
+
)
|
48 |
+
)
|
49 |
+
|
50 |
+
# Create model and randomize all weights
|
51 |
+
model = GroundingDinoForObjectDetection(config)
|
52 |
+
|
53 |
+
torch.manual_seed(0) # Set for reproducibility
|
54 |
+
for name, param in model.named_parameters():
|
55 |
+
param.data = torch.randn_like(param)
|
56 |
+
|
57 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
58 |
+
|
59 |
+
print(model.num_parameters()) # 7751525
|
60 |
+
```
|
61 |
|
62 |
|
63 |
## Model Details
|